As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
If after using -READ, your &LASTDAY variable shows funny characters that would be due to a binary representation of numbers in the HOLD file. If that's the case, make sure the value your SQL passthru returns is "seen" as a character (i.e. select to_char(lastday) as lastday from blah ) -OR- when creating the HOLD file, use ALPHA format. Just something to keep in mind.
If the sole purpose of the SQL pass through is to determine if the last day of February in a given year is the 28th or the 29th, then this can be accomplished using a DEFINE FUNCTION. The defined function would include the logic for determining if a year is a leap year. If you are interested I'll look through my notes and post the code.
Posts: 13 | Location: New York City | Registered: March 01, 2010
Ira, you make a very valid point. I don't think I read Rodney's requirement in detail but focused on his need to "capture SQL output in an &variable" .
In following your line of thought, it is very easy to determine the last day of any month in any year (leap or otherwise) in "pure" WebFOCUS style using DATEMOV:
-* "Regular" year
SET TESTDATE=20110201
-RUN
-SET &LASTDAY=EDIT(DATECVT(DATEMOV(DATECVT(&YYMD, 'I8YYMD', 'YYMD'), 'EOM'), 'YYMD', 'A8YYMD'), '$$$$$$99');
-TYPE &LASTDAY
-* Leap year
SET TESTDATE=20080201
-RUN
-SET &LASTDAY=EDIT(DATECVT(DATEMOV(DATECVT(&YYMD, 'I8YYMD', 'YYMD'), 'EOM'), 'YYMD', 'A8YYMD'), '$$$$$$99');
-TYPE &LASTDAY
To add on to the very helpful suggestions here I just wanted to note some things I noticed for any future readers of this thread.
At first I was using this code
SQL SELECT LAST_DAY FROM XYZ ; TABLE ON TABLE HOLD AS TMP_XYZ END -RUN TABLE FILE TMP_XYZ PRINT LAST_DAY ON TABLE HOLD END -RUN -READ HOLD &TMP.A6 -TYPE TEST: &TMP; -EXIT
When testing this, my output for &TMP was actually blank, or it came out to
TEST:
Thanks to the suggestion from njsden I changed it so it would then set the value pulled to a CHAR.
SQL SELECT TO_CHAR(LAST_DAY) LAST FROM XYZ ; TABLE ON TABLE HOLD AS TMP_XYZ END -RUN TABLE FILE TMP_XYZ PRINT LAST ON TABLE HOLD END -RUN -READ HOLD &TMP.A6 -TYPE TEST: &TMP; -EXIT
Which gave me what I wanted, though I had to use a TRUNCATE to make sure there were no extra spaces lurking around
That define function is awesome too, I was mainly trying to do the -READ to play with it but I will try that define function too.
Thanks so much for the replies, I am much more encouraged to learn Webfocus now with such a great community!
Rodney, all in light of contributing to your learning I'd like to make a few comments on your sample code.
1) Avoid using LAST as a field name as it is a WebFOCUS reserved word which allows to get the value of a field from the previous record (or previous entry in the internal matrix in case of SUM requests). Though it is working now in your example it *might* not do so in future versions of the product. So:
SELECT TO_CHAR(LAST_DAY) LAST_DAY FROM XYZ
is a better choice.
2) Whenever possible, give your HOLD files a name. It is not required but it is a practice I've embraced to save me from headaches especially when many HOLD files are involved in a report process.
ON TABLE HOLD AS HLASTDAY
3) The syntax of -READ suggests to use a dot (.) before and after the type/length declaration of the &variable:
-READ HLASTDAY &TMP.A6.
4) Finally, -TYPE does not require a semicolon at the end of the line.
Though those suggestions may look silly or unnecessary, I share them just because after our recent upgrade from WF 5.3 to WF 7.7 we found a few lines of code that stopped running due to code tightening (stricter syntax rules) in the newer version.