Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Date in report header based off of SQL query
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Date in report header based off of SQL query
 Login/Join
 
Member
posted
I am using a SQL query in my report with the where condition:

VARIABLE BETWEEN TRUNC(SYSDATE-3,'MON') AND LAST_DAY(SYSDATE-3)

How can I get the header of the report to show the max date of the query result?

Currently doing something like:

HEADING
"Original booking date month-to-date through &DATEDMtYY"


Version is 8008

Thank you Smiler

This message has been edited. Last edited by: FP Mod Chuck,
 
Posts: 10 | Registered: June 04, 2019Reply With QuoteReport This Post
Silver Member
posted Hide Post
Not totally certain how to do this in one pass, but you could save your results in a hold file, then access that hold file to save your max value as a variable, then create your final report and place that variable in the header.

So a quasi example:

  

SQL
SELECT *
FROM GGORDER
WHERE ORDER_DATE BETWEEN '1996/01/01' AND '1996/02/01';
TABLE ON TABLE HOLD AS HOO1
END
-RUN

-SET &ORDER_DATE = ;

TABLE FILE HOO1
BY HIGHEST 1 ORDER_DATE
ON TABLE HOLD AS MAX_DATE
END
-RUN
-READFILE MAX_DATE
-RUN
-TYPE ORDERDATE = &ORDER_DATE

TABLE FILE HOO1
PRINT ORDER_DATE
STORE_CODE
ORDER_NUMBER
QUANTITY
ON TABLE SUBHEAD
"Original booking date month-to-date through &ORDER_DATE"
ON TABLE PCHOLD FORMAT HTML
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
ENDSTYLE
END

-RUN



Hope this helps.

This message has been edited. Last edited by: Mike Williams,


WF Version 8105
 
Posts: 41 | Registered: October 07, 2015Reply With QuoteReport This Post
Master
posted Hide Post
quote:
I am using a SQL query


What SQL engine are you using? Sql Server, Oracle, etc?


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 529 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Member
posted Hide Post
quote:

What SQL engine are you using? Sql Server, Oracle, etc?


Oracle
 
Posts: 10 | Registered: June 04, 2019Reply With QuoteReport This Post
Expert
posted Hide Post
Any reason that you've decided the following would not suffice?

ON TABLE SUBHEAD
"Original booking date month-to-date through <MAX.ORDER_DATE"


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.06 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5637 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by Tony A:
Any reason that you've decided the following would not suffice?

ON TABLE SUBHEAD
"Original booking date month-to-date through <MAX.ORDER_DATE"


T



I cannot select 'ORDER_DATE' in the query because then I would have to Group By it as well which would break the results. I could aggregate it in the SQL query to avoid grouping by it but I was unaware I could reference a SQL variable within the HEADING quotes with '<'. Looks like my silly brain was over complicating the issue Smiler


It works with the following:

SELECT
MAX(ORDER_DATE) AS MAXDATE

HEADING
"Original booking date month-to-date through
Thank you
 
Posts: 10 | Registered: June 04, 2019Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by Mike Williams:
Not totally certain how to do this in one pass, but you could save your results in a hold file, then access that hold file to save your max value as a variable, then create your final report and place that variable in the header.

So a quasi example:

  

SQL
SELECT *
FROM GGORDER
WHERE ORDER_DATE BETWEEN '1996/01/01' AND '1996/02/01';
TABLE ON TABLE HOLD AS HOO1
END
-RUN

-SET &ORDER_DATE = ;

TABLE FILE HOO1
BY HIGHEST 1 ORDER_DATE
ON TABLE HOLD AS MAX_DATE
END
-RUN
-READFILE MAX_DATE
-RUN
-TYPE ORDERDATE = &ORDER_DATE

TABLE FILE HOO1
PRINT ORDER_DATE
STORE_CODE
ORDER_NUMBER
QUANTITY
ON TABLE SUBHEAD
"Original booking date month-to-date through &ORDER_DATE"
ON TABLE PCHOLD FORMAT HTML
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
ENDSTYLE
END

-RUN



Hope this helps.


When I attempted this solution I was getting

(FOC295) A VALUE IS MISSING FOR: &MAXDATE

Not sure the issue, but thanks for the lead!
 
Posts: 10 | Registered: June 04, 2019Reply With QuoteReport This Post
Silver Member
posted Hide Post
Could you share your code?


WF Version 8105
 
Posts: 41 | Registered: October 07, 2015Reply With QuoteReport This Post
Silver Member
posted Hide Post
Oh, I thought you didn't have a resolution on the question.

You may want to edit your post and put a [SOLVED] in the subject.


WF Version 8105
 
Posts: 41 | Registered: October 07, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Date in report header based off of SQL query

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.