Focal Point
Reading a SQL Result into a variable

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4881002171

June 08, 2006, 08:57 PM
madhavi
Reading a SQL Result into a variable
I have a table which has 7 flags. Each row in that table has a key value and each row will have only one of teh flags turned on

so, if I query by the PK of that table, I will see one and only one flag ON. Based on the flag which is ON, I will know which table to query from for generating my report.

Now, can any one tell me how do i implement my top IF condition?
Can I read that flag into a local variable and say like

IF FLAG1 = 'Y' THEN

TABLE FILE MASTER1
...
END
ELSE IF FLAG2 = 'Y' THEN
TABLE FILE MASTER2
...
END
ELSE IF FLAG3 ='Y' THEN
TABLE FILE MASTER3
...
END
END
June 09, 2006, 02:54 AM
Mikel
Two reports, first to retrieve Master name (using a defined field with your IF condition) and second to generate your report (I'm supposing the structure of differents tables are the same)

-* Define MASTER in function of flags.
DEFINE FILE ptable
  MASTER/A64 = 
    IF FLAG1 EQ 'Y' THEN 'MASTER1' ELSE
    IF FLAG2 EQ 'Y' THEN 'MASTER2' ELSE
    ...
    ELSE '?' ;
END

-* Report to retrieve MASTER.
TABLE FILE ptable
  PRINT MASTER
  WHERE PK ...
  ON TABLE HOLD FORMAT ALPHA
END
-RUN

-* Read MASTER name.
-DEFAULT &MASTER = '?' ;
-READ HOLD &MASTER.A64.
-TYPE MASTER = &MASTER
-IF &MASTER EQ '?' THEN GOTO ... ;

-* Depending structures, we can use
-* -INCLUDE &MASTER or EX &MASTER or complex IF THEN GOTO

-* Final report
TABLE FILE &MASTER
...
END
-RUN

Regards,
Mikel

This message has been edited. Last edited by: Mikel,


WebFOCUS 8.1.05, 8.2.01