Focal Point
[SOLVED] SQL passthru with sub selects

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

September 18, 2009, 03:44 PM
dev532
[SOLVED] SQL passthru with sub selects
Hi,

This Works-
SQL
SELECT CAR,MODEL FROM CAR ;
TABLE FILE SQLOUT
PRINT *
END

This DOES NOT!
SELECT CAR,MODEL
FROM
( SELECT * FROM CAR )
;
TABLE FILE SQLOUT
PRINT *
END

it gives me this error message
(FOC012) THE WORD 'FILE' OR THE FILENAME APPEARS TWICE
BYPASSING TO END OF COMMAND
(FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: HOLD10

Thanks for your help and suggestions.

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


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
September 18, 2009, 04:49 PM
N.Selph
The first is correct syntax for SQL Translation.
The second is partial syntax for SQL Passthrough. They are not the same. The SQL Passthrough needs the information statements on the RDBMS database you are connecting to, which you don't supply. Just as well -- the CAR file is FOCUS, not RDBMS anyway.


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
September 18, 2009, 05:24 PM
dev532
So, I would have to save the output from the first SQL statement(inner query) to a hold file and then perform another SQL (outer query) against the hold file?

thanks!


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
September 18, 2009, 06:35 PM
N.Selph
If you were really doing SQL Passthrough to an RDBMS, you can use a subselect. Not in SQL Translation.


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
September 19, 2009, 01:16 AM
BlueZone
In our trials, this techinque of coding faux SQL pass-through statements against non-RDMBS data sources has very limited functionality. Forget going as far as sub-selects, it does not support most of the basic native SQL functions either.

However when using "SQL DB2" or "SQL SQLMSS" against a real RDBMS, the query can be as complex as anywhere else.

Sandeep Mamidenna


-------------------------------------------------------------------------------------------------
Blue Cross & Blue Shield of MS
WF.76-10 on (WS2003 + WebSphere) / EDA on z/OS + DB2 + MS-SQL
MRE, BID, Dev. Studio, Self-Service apps & a dash of fun !! Music
September 21, 2009, 10:25 AM
dev532
I am not connecting to any RDBMS(not using SQL passthru).

How can I capture the output from a simple SQL translator to a hold file so that i can create a report using that hold file. Is that possible?

SQL
SELECT COUNTRY,CAR FROM CAR ;
END


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
September 21, 2009, 11:14 AM
Francis Mariani
SQL
SELECT CAR,MODEL
FROM
( SELECT * FROM CAR )
;
TABLE ON TABLE HOLD AS H001
END

TABLE FILE H001
PRINT *
END

works without any errors.

The "TABLE FILE SQLOUT" syntax may be reserved for DBMS SQL only


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 21, 2009, 11:49 AM
dev532
Hi Francis.

I had the exact same thing at my end and it wasn't working this morning.So, I thought something was wrong.Hmm.

It works now.Thanks!!


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
September 22, 2009, 04:26 PM
Dan Pinault
It works even without the HOLD

SQL
SELECT CAR, MODEL
FROM 
(SELECT * FROM CAR WHERE COUNTRY = 'ENGLAND')
;
ON TABLE PCHOLD FORMAT HTML
END



7.7.05M/7.7.03 HF6 on Windows Server 2003 SP2 output to whatever is required.
September 23, 2009, 05:04 AM
Danny-SRL
Simply,

  
SQL
SELECT SSALES, COUNTRY
FROM
(SELECT SUM(SALES) SSALES, COUNTRY, CAR FROM CAR WHERE SALES > 0 GROUP BY COUNTRY, CAR)
;
GROUP BY SSALES DESC
END



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