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     Using dialog manager in sql passthru

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Using dialog manager in sql passthru
 Login/Join
 
Member
posted
Hi,

Is it possible to use dialog manager in a sql passthru to build a dynamic select statement without breaking the sql. I need to test the value of an amper variable and modify the select statement based on its value. If so, does anyone have an example?

Thanks...
 
Posts: 19 | Registered: January 04, 2005Report This Post
Virtuoso
posted Hide Post
Certainly.

Bear in mind that the fex is executed in two stages:
In stage 1, Dialog Manager (which does not understand Focus syntax) performs all the DM directives (-if, -set, -repeat etc.); and performs substitution of DM &vars imbedded in the Focus lines, and stacks them for execution in stage 2. Stage 1 ends at end of the fex, or when -RUN, or -EXIT is encountered.
In stage 2, Focus executes the stacked lines.

So you can insert DM statements between and around your lines of SQL and TABLE code, and perhaps imbed DM variables (amper vars) in the SQL code itself.

Add -RUN after the END statement if you want to resume DM processing after the data retrieval is complete, e.g., to test &LINES), and there you are.

Just make sure that the SQL (and TABLE) code generated will be valid, for all possible combinations of conditions (amper parameters).

For example, to screen on one or more columns, depending on input parameters, I have used code like this:

-SET &WHERE='WHERE';

-IF &ALPHA EQ ' ' GOTO ALPHA.X;
&WHERE (ALPHA = '&ALPHA')
-SET &WHERE='OR';
-ALPHA.X

-IF &BETA EQ ' ' GOTO BETA.X;
&WHERE (BETA = '&BETA')
-SET &WHERE='OR';
-BETA.X

-IF &GAMMA EQ ' ' GOTO GAMMA.X;
&WHERE (GAMMA= '&GAMMA)
-SET &WHERE='OR';
-GAMMA.X
. . .

This ensures that the first clause of the WHERE condition that the fex generates will start with WHERE, and all subsequent ones with OR.
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Member
posted Hide Post
Thanks Jack...I'll give that a try. Until your response, I was trying to do something like this. This is just a test query but it works...
-SET &SQLTEST = IF &DATETYPE EQ 'Bar Date' THEN ',a.assignment_id FROM PAL.SD sd, PAL.SD_ASSIGNMENT a WHERE a.sd_number = sd.sd_number;'<br />-ELSE 'FROM PAL.SD sd;';<br /><br /><br />SET SQLENGINE=SQLORA<br />SQL SET SERVER &MYSERV<br />SQL SELECT sd.sd_number,<br />           sd.doe_s_number<br />           &SQLTEST<br />END
However, it breaks if I try to pass an amper variable in the where string. It gives me an error about mssing quotes. Any ideas how I can get this to work?

-SET &SQLTEST = IF &DATETYPE EQ 'Bar Date' THEN ',a.assignment_id FROM PAL.SD sd, PAL.SD_ASSIGNMENT a WHERE a.sd_number = s.sd_number and a.begin_date >= &date1;'<br />-ELSE 'FROM PAL.SD sd;';<br /><br />SET SQLENGINE=SQLORA<br />SQL SET SERVER &MYSERV<br />SQL SELECT sd.sd_number,<br />           sd.doe_s_number<br />           &SQLTEST<br />END
 
Posts: 19 | Registered: January 04, 2005Report This Post
Expert
posted Hide Post
Because you're embedding a DM variable inside another, you should use .EVAL.
You may also require quotes around the date value:

-SET &SQLTEST = IF &DATETYPE EQ 'BAR DATE'
- THEN ',A.ASSIGNMENT_ID FROM PAL.SD SD, PAL.SD_ASSIGNMENT A WHERE A.SD_NUMBER = S.SD_NUMBER AND A.BEGIN_DATE >= ''&DATE1.EVAL;'''
- ELSE 'FROM PAL.SD SD;';

-TYPE &SQLTEST
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Member
posted Hide Post
Here's a trimmed down version of one that works fine for us:

-DEFAULT &FRDATE = 'NONE' ;
-IF &FRDATE EQ 'NONE' GOTO ERR_DATE ;

-SET &FRDATEL = EDIT(&FRDATE,'9999/99/99') ;
-TYPE Getting calls since &FRDATEL ..


-RUN

SQL SQLSYB

select
b.meetingDate
,b.meetingBucketId
...
from cmgMeetingBucket b

where b.meetingDate >= "&FRDATEL"
and ...
;

TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS H010 FORMAT ALPHA
END
...
-ERR_DATE
 
Posts: 15 | Location: New York | Registered: April 02, 2004Report 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     Using dialog manager in sql passthru

Copyright © 1996-2020 Information Builders