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     [SOLVED] Include holdfile in sql statement

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Include holdfile in sql statement
 Login/Join
 
Platinum Member
posted
Hi,

Is it possible to include a holdfile in a sql statement. (see example)

- first select values from CAR
- Print them to a holdfile
- use second select and use holdfile by
including it (I now it has to be a fex)
- finally print result

Simple example :

-* First selection
SQL
SELECT DISTINCT COUNTRY
FROM
( SELECT *
FROM CAR
WHERE COUNTRY IN ('ENGLAND', 'JAPAN', 'ITALY' )
)
;
TABLE ON TABLE HOLD AS H001
END

-* Make a holdfile with the IN values
TABLE FILE H001
PRINT COUNTRY AS ''
COMPUTE COMMA/A1 = IF COUNTRY EQ 'JAPAN' THEN '' ELSE ',';
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS INVALUES
ON TABLE NOTOTAL
END

-* New selection based on holdfile
SQL
SELECT COUNTRY, CAR
FROM
( SELECT *
FROM CAR
WHERE COUNTRY IN (
-INCLUDE INVALUES -*holdfile
)
)
;
TABLE ON TABLE HOLD AS H002
END

TABLE FILE H002
PRINT *
END

This message has been edited. Last edited by: <Kathryn Henning>,
 
Posts: 103 | Registered: March 18, 2008Report This Post
Virtuoso
posted Hide Post
Hi Vincent!

Yes you can.
However, in your example you have 2 problems:
1. Your HOLD file should be in FORMAT ALPHA and should have the .fex extension.
2. You have to ensure that JAPAN is in fact the last value encountered

  
SQL
SELECT DISTINCT COUNTRY
FROM
( SELECT * 
 FROM CAR 
 WHERE COUNTRY IN ('ENGLAND', 'JAPAN', 'ITALY' ) 
)
;
TABLE ON TABLE HOLD AS H001
END

-* Make a holdfile with the IN values
FILEDEF INVALUES DISK INVALUES.FEX
TABLE FILE H001
PRINT 
 COMPUTE COMMA/A1 = IF COUNTRY EQ 'JAPAN' THEN '' ELSE ',';
BY COUNTRY
ON TABLE SAVE AS INVALUES
END

-* New selection based on holdfile
SQL
SELECT COUNTRY, CAR
FROM
( SELECT * 
 FROM CAR 
 WHERE COUNTRY IN (
-INCLUDE INVALUES 
 )
)
;
TABLE ON TABLE HOLD AS H002
END

TABLE FILE H002
PRINT *
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Virtuoso
posted Hide Post
Unfortunately, there is an error in your code Danny and without quotes embracing the alpha values in a IN clause I don't know how it can work.

It may not be as elegant as it should, but it works:
SQL
SELECT DISTINCT COUNTRY
FROM
( SELECT * 
 FROM CAR 
 WHERE COUNTRY IN ('ENGLAND', 'JAPAN', 'ITALY') 
)
;
TABLE ON TABLE HOLD AS H001
END

-TYPE &LINES

-SET &INVALUES = '';
-SET &I = 0;
-REPEAT GENLST &LINES TIMES
-SET &I = &I + 1;
-READ H001 &VAL.&I.A10.
-TYPE &VAL.&I
-SET &INVALUES = &INVALUES || '''' || &VAL.&I || '''';
-SET &INVALUES = IF &I LT &LINES THEN &INVALUES || ',' ELSE &INVALUES;
-GENLST

-TYPE &INVALUES

SQL
SELECT COUNTRY, CAR
FROM
( SELECT * 
 FROM CAR 
 WHERE COUNTRY IN (
&INVALUES
 )
)
;
TABLE ON TABLE HOLD AS H002
END

TABLE FILE H002
PRINT *
END


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Virtuoso
posted Hide Post
OOOPS!
Quite true.
Change this:
  
FILEDEF INVALUES DISK INVALUES.FEX
TABLE FILE H001
PRINT 
 COMPUTE COMMA/A1 = IF COUNTRY EQ 'JAPAN' THEN '' ELSE ',';
BY COUNTRY
ON TABLE SAVE AS INVALUES
END

To this:
  
FILEDEF INVALUES DISK INVALUES.FEX
TABLE FILE H001
PRINT 
 COMPUTE QCOUNTRY/A12='''' || COUNTRY || '''';
 COMPUTE COMMA/A1 = IF COUNTRY EQ 'JAPAN' THEN '' ELSE ',';
BY COUNTRY NOPRINT
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS INVALUES
END


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Platinum Member
posted Hide Post
Thanks guys, for all your help.
I got it working.

Kind regards

Mark
 
Posts: 103 | Registered: March 18, 2008Report 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     [SOLVED] Include holdfile in sql statement

Copyright © 1996-2020 Information Builders