Focal Point
[CLOSED] Optional Variable

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

October 26, 2010, 10:22 AM
RG
[CLOSED] Optional Variable
SELECT
A.AUTH_ID as AUTHORITY NUMBER,
A.CUST_ID AS ID,
A.QLF_SET_ID AS QUALIFIER_SET,
A.INCD_DT AS INCD_DT,
A.EXP_DT AS EXP_DT,
A.QLF_SET_DESC AS DESCRIPTION
FROM
MMST_HEADER A,
(SELECT
AUTH_ID,
MAX(PAUTH_SEQ_NUMB) AS MXSEQ
FROM
MMST_HEADER
GROUP BY 1) B
WHERE
A.AUTH_ID = B.AUTH_ID AND
A.PAUTH_SEQ_NUMB = MXSEQ AND
A.AUTH_ID = 'EP2301' /* THIS IS A VARIABLE AND SHOULD BE REQUIRED */
AND EXP_DT > '2008-04-12' /* THIS IS A VARIABLE AND SHOULD BE REQUIRED */
AND PROV_ID IN ('02','03','04') /* THIS IS A VARIABLE AND SHOULD NOT BE REQUIRED */

ORDER BY PROV_ID, QUALIFIER_SET

;

-DEFAULT &AUTH_ID='EP2301';
-DEFAULT &EXP-DT='2008-01-12';
-DEFAULT PROV_ID-'';-* I have got three values '02','03','04'.So how should I project these three values as the default variables.


-*If it was a single value for PROV_ID ex.'02' I could have removed it from the where statement and write this statment.

-SET &WHERE_PROV_ID=IF &PROV_ID EQ '' THEN '' ELSE 'AND PROV_ID=''&PROV_ID'';

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


WebFocus 7.6.11
Windows XP
Excel
October 26, 2010, 10:45 AM
GamP
If your CUST_ID is optional then you need to have something that tells the code that it is optional. And you can check on that. For instance:
AUTH_ID='&AUTH_ID'
AND CUST_NBR='&CUST_NBR'
-IF &OPTIONAL EQ 'YES' THEN GOTO :Continue;
AND CUST_ID IN ('02','03','04')
-:Continue



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
October 26, 2010, 05:15 PM
Waz
As Gamp asks, What makes the test optional, a supplied value, a data value, something else ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 26, 2010, 05:24 PM
RG
quote:
AND PROV_ID IN ('02','03','04') /* THIS IS A VARIABLE AND SHOULD NOT BE REQUIRED */



The values '02','03','04' are already supplied.I am confused as 'IN' is present.

AND PROV_ID IN ('02','03','04') /* THIS IS A VARIABLE AND SHOULD NOT BE REQUIRED */


WebFocus 7.6.11
Windows XP
Excel
October 26, 2010, 05:32 PM
Waz
I am confused, as a test againsta list requires an IN statement.

In what circumstances should this test be done, or not be done ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 27, 2010, 06:49 AM
GamP
quote:
AND PROV_ID IN ('02','03','04') /* THIS IS A VARIABLE AND SHOULD NOT BE REQUIRED */
In this statement it is not variable. So if you want to make it variable, then you have to create something to make it variable. And since it is obviously required to be able to select more then 1 value, it has to be a multi-select variable. If you create such a variable that also can contain a sort of select all value, then this variable will be returned to the fex with value FOC_NONE or with the selected values in the form "'02' OR '03' OR '04'". So, if that is the case, the only thing you need to do should be to specify 'AND PROV_ID EQ &PROV_ID', provided the variable is called &PROV_ID. Otherwise please explain exactly what it is that you're looking for.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988