Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Parameter to SQL Passthru

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Parameter to SQL Passthru
 Login/Join
 
Platinum Member
posted
Is there any way to pass a parameter to a script of SQL passthru? I'm trying to cut to the chase on a code that will return values based on date that won't exaust time on the answer-set and recalc on the Report server. Basically I'd like to do this:

SQL SQLORA
SELECT * FROM TABLEA WHERE TABLEA_DATE > &PARAM;
TABLE FILE SQLOUT
PRINT
*
ON TABLE HOLD AS MYHOLD
END

Anyone done something like this before?

Thanks!
 
Posts: 87 | Registered: August 03, 2006Report This Post
Expert
posted Hide Post
Sure, this is done all the time.

With Dialog Manager, the variable value replaces the variable name before the line of code is processed. The only case this does not happen is when a variable contains another variable, you have to append .EVAL to the variable name - but that's another story.

Be aware that Date-Time columns in relational dbs are treated as alpha in SQL, you have to use quotes. Also, depending on the type of relational db, the date should probably use "-" as separator, e.g. '2006-11-27'.

As far as I know, this is the syntax to use:

SET SQLENGINE=SQLORA
SQL
SELECT * FROM TABLEA WHERE TABLEA_DATE > '&PARAM';
TABLE ON TABLE HOLD AS MYHOLD
END

You may also need to provide the server name, if more than one WF data adapter is defined:

SQL SET SERVER server-name

This goes between the SQLENGINE command and the SELECT command.

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
I've verified that that works, but will it detect the fact that there is a parameter if I put it the same way I had in my previous post? Like an amper-variable? Or would SQL not know what to do with it?
 
Posts: 87 | Registered: August 03, 2006Report This Post
Expert
posted Hide Post
Dialog Manager takes care of the variable, SQL doesn't even get to see it.

If you add this command at the top of your program:

-SET &ECHO=ALL;

you will be able to see the program code and you will see that the variable has been translated before the SQL is run.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
I keep trying it but for some reason my SQL results and my results from Developer are not the same. I'm trying to use the SQL function "to_date" so that the user can enter dates in the format 'MM/DD/YYYY' instead of 'YYYY/MM/DD'. Does this change anything on this end?

This message has been edited. Last edited by: gregson06,
 
Posts: 87 | Registered: August 03, 2006Report This Post
Platinum Member
posted Hide Post
I am convinced that this is the issue, infact when I copy the script exactly between the sql tool and Developer I get totally different answers, as if FOCUS is looking for something else. Nothing seen differently with ECHO=ON, I'm not sure where else to look or how else to rephrase it.

This message has been edited. Last edited by: gregson06,
 
Posts: 87 | Registered: August 03, 2006Report This Post
Expert
posted Hide Post
Your SQL date selection can be Month Day Year if you wish - SQL figures out the date.

Don't bother using the SQL to_date function.

If the user enters a date with slashes, use Dialog Manager to change the slashes to dashes and use the new variable in the SQL command, e.g.:
-SET &DATE1 = '21/12/2006';
-SET &DATE2 = EDIT(&DATE1,'99$-99$-9999');
-TYPE &DATE1 &DATE2

(The $ means ignore the /, the - means add a -.)


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
Francis,

I'll try using this format. I managed to get the dates to work using TABLE but not through the SQL Passthru. I'll keep the forum posted incase it's not.

Thanks again!

This message has been edited. Last edited by: gregson06,
 
Posts: 87 | Registered: August 03, 2006Report This Post
Platinum Member
posted Hide Post
G :
To add to FM's note, you should be able to use DM to set dates and use the variables in your SQL. But the important thing is to make sure that you are using the correct date formats.

At our site for instance, when we use SQL-passthru to DB2, we have use the CCYY-MM-DD format for DATE format fields. Whereas the same field would be used as just CCYYMMDD if I was coding the same WHERE in FOCUS code.
Use (SET XRETRIEVAL=OFF) in combination with (-SET &ECHO=ALL; ) to see how the varaible is being plugged in the SQL code. This will check the SQL syntax and return you the code without actually executing it.
-*
SET XRETRIEVAL=OFF
-SET &ECHO=ALL;
-*
-SET &TODY1=EDIT(&YYMD,'9999-99-99');
-*
SQL DB2
SELECT
FLD1
,FLD2
FROM DBNME.TBL1 A
WHERE PROCESS_DATE = '&TODY1.EVAL'
;
TABLE
ON TABLE HOLD AS HOLD000
END
-RUN
-*

Hope that helps.
Sandeep M.


-------------------------------------------------------------------------------------------------
Blue Cross & Blue Shield of MS
WF.76-10 on (WS2003 + WebSphere) / EDA on z/OS + DB2 + MS-SQL
MRE, BID, Dev. Studio, Self-Service apps & a dash of fun !! Music
 
Posts: 218 | Location: Jackson, MS | Registered: October 31, 2006Report This Post
Master
posted Hide Post
I do this all the time. Assuming the date is valid and in mm/dd/yyyy format with the slashes, here's what we do:

-SET &MYDATE=EDIT(&PARAM,'99$99$9999');
SET SQLENGINE=SQLORA
SQL
SELECT *
FROM TABLEA
WHERE TABLEA_DATE > TO_DATE('&MYDATE','MMDDYYYY');
TABLE ON TABLE HOLD AS MYHOLD
END


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Parameter to SQL Passthru

Copyright © 1996-2020 Information Builders