Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Table File Join within SQL SQLDBC query
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Table File Join within SQL SQLDBC query
 Login/Join
 
Member
posted
Does anyone have an example or explanations on how to join a WF Table File within an SQLDBC query?

I built a WF table file (CARLIST) holding a list of cars that I would like to use to limit the number of records brought back while running an SQL query against our railcar DW table (CARMOVES) with millions of records. Here is an example of what I have tried so far, but due to the number of car records in the CARMOVES table - this times out.

SQL SQLDBC

SELECT car, waybill, nettons

FROM dw database.car_movement_table A

WHERE A.CAR IN FILE CARLIST
;
TABLEF FILE SQLOUT
ON TABLE HOLD AS X
TABLE FILE X
PRINT *

This message has been edited. Last edited by: FP Mod Chuck,


WF 8
 
Posts: 13 | Registered: September 28, 2017Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Tim,

instead of creating a hold file , you can directly join your tables in sql Passthrough ,

OR if you have limited records in hold file catlist you can read the records and assign those records to a variable using loop . and then pass that variable in where statement .

Try This code,
 -DEFAULTH &CAR_UNIT = '';
-SET &CAR_FILTER = '';
-SET &ECHO = ALL;
-RUN
TABLE FILE CAR
BY CAR AS 'CAR_UNIT'
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS CAR_LIST
END
-RUN
-SET &CAR_FILTER = '(';
-REPEAT :FILTERCAR &LINES TIMES
-READFILE CAR_LIST
-SET &UNITLEN = ARGLEN(&CAR_UNIT.LENGTH,&CAR_UNIT,'I2') ;
-SET &CARUNIT= TRIM('T',&CAR_UNIT, &CAR_UNIT.LENGTH, ' ', 1, 'A&UNITLEN.EVAL');
-SET &CAR_FILTER = &CAR_FILTER ||''''||&CARUNIT||''',';
-:FILTERCAR
-SET &CAR_FILTER = SUBSTR(&CAR_FILTER.LENGTH, &CAR_FILTER.QUOTEDSTRING, 1, &CAR_FILTER.LENGTH - 2 , &CAR_FILTER.LENGTH - 2, 'A&CAR_FILTER.LENGTH') || ''')';


SQL SQLDBC

SELECT car, waybill, nettons

FROM dw database.car_movement_table A

WHERE A.CAR IN &CAR_FILTER; 



Run time code will become like ,

 SQL SQLDBC
 SELECT car, waybill, nettons
 FROM dw database.car_movement_table A
 WHERE A.CAR IN ('ALFA ROMEO','AUDI','BMW','DATSUN','JAGUAR','JENSEN','MASERATI','PEUGEOT','TOYOTA','TRIUMPH')  ;
 


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10
 
Posts: 186 | Location: Infobuild India | Registered: August 28, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Chaudhary,
Another way, without a loop:
  
DEFINE FILE CAR
QCAR/A20='''' || CAR || ''',';
END
TABLE FILE CAR
SUM CNT.CAR
SUM QCAR
ACROSS CAR
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS CAR_LIST
END
-RUN
-READ CAR_LIST &CLEN.A5 
-RUN
-SET &LEN=&CLEN * 20;
-READ CAR_LIST &CLEN.A5. &CARLIST.A&LEN.EVAL.
-SET &CARLIST=TRIM('T', RJUST(200, &CARLIST, 'A200'), 200, ',', 1, 'A200');
-TYPE &CARLIST

&CARLIST contains:
  
'ALFA ROMEO',       'AUDI',             'BMW',              'DATSUN',           'JAGUAR',           'JENSEN',           'MASERATI',         'PEUGEOT',          'TOYOTA',           'TRIUMPH'


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

 
Posts: 1880 | Location: Tel Aviv, Israel | Registered: March 23, 2006Reply With QuoteReport This Post
Member
posted Hide Post
Thank you very much, I used variable loop logic and this did the trick. Good thinking - I will also check out the second method without loop. Much appreciated!


WF 8
 
Posts: 13 | Registered: September 28, 2017Reply With QuoteReport This Post
Member
posted Hide Post
David thanks for the response as well. Three good options here that I will make sure to keep in mind in the future. thanks


WF 8
 
Posts: 13 | Registered: September 28, 2017Reply With QuoteReport This Post
Platinum Member
posted Hide Post
quote:
Chaudhary,
Another way, without a loop:


Thanks Danny It works . Good One


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10
 
Posts: 186 | Location: Infobuild India | Registered: August 28, 2015Reply With QuoteReport This Post
Member
posted Hide Post
I tried the 'without a loop' code this morning and am having some issues. So, there are only 21 cars in the car table (MT)this morning and the code is failing on the -READ CAR_LIST &CLEN.A5 line


this runs through the table file hold across cars just fine and fails for 'unrecocgnized format of amper variable -READ CAR_LIST &CLEN.A5 &CARLIST.A&LEN.EVAL.

MT is the file holding the car list, and the car field is A14.

DEFINE FILE MT
QCAR/A20='''' || CAR || ''',';
END

TABLE FILE MT
SUM CNT.CAR
SUM QCAR
ACROSS CAR
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS CAR_LIST
END


-RUN
-READ CAR_LIST &CLEN.A5
-RUN
-SET &LEN=&CLEN * 20;
-READ CAR_LIST &CLEN.A5. &CARLIST.A&LEN.EVAL.
-SET &CARLIST=TRIM('T', RJUST(200, &CARLIST, 'A200'), 200, ',', 1, 'A200');
-TYPE &CARLIST


WF 8
 
Posts: 13 | Registered: September 28, 2017Reply With QuoteReport This Post
Expert
posted Hide Post
A slightly more compact no-loop method by relying upon the Title values within a COMT file (comma delimited with titles).

Because this only reads the first line, removes spaces and truncates the result, we can set the length of read to be ([length of CAR field + 2] * number of output records) - 1 and not have to bother with getting the count from within the table request.

-DEFAULTH &CARLIST = ''
TABLE FILE CAR
SUM COMPUTE BLNK/A1 = ''; AS ''
ACROSS CAR
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS CAR_LIST FORMAT COMT
END
-RUN
-SET &LEN=(&RECORDS * 22)-1;
-READ CAR_LIST &CARLIST.A&LEN.EVAL.

-SET &CARLIST=STRREP(&CARLIST.LENGTH, &CARLIST.QUOTEDSTRING, 1, ' ', 0, 'x',  &CARLIST.LENGTH, 'A&CARLIST.LENGTH');
-SET &CARLIST=TRUNCATE(&CARLIST);
-TYPE &CARLIST


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, 8.2.02M, 8.2.03, 8.2.04 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.04 standalone on Windows 10 
 
Posts: 5420 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Tony,
Nice (as usual)...

Tim,
I see your problem. It is here:
quote:

-SET &CARLIST=TRIM('T', RJUST(200, &CARLIST, 'A200'), 200, ',', 1, 'A200');


My mistake. It should read:
  
-SET &CARLIST=TRIM('T', RJUST(&CLEN, &CARLIST, 'A&CLEN.EVAL'), &CLEN, ',', 1, 'A&CLEN.EVAL');


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

 
Posts: 1880 | Location: Tel Aviv, Israel | Registered: March 23, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
Thanks Danny,

I tried to use SUM CAR ACROSS CAR and then grab the second line in the output COMT or the first line in a COM (as it would already be the exact variable this needs) but didn't give too much effort into it Wink

Seasons greetings to you and the team in Israel

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, 8.2.02M, 8.2.03, 8.2.04 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.04 standalone on Windows 10 
 
Posts: 5420 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Table File Join within SQL SQLDBC query

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.