SQL has a nice command, "TOP 1", which takes, as you can imagine, the TOP 1 record based on any remaining selection criteria (if any) and returns ONE record. The question is: What is the WebFOCUS CODE that produces the SQL Code for "TOP 1"? This would be seen in the result of a "SQL Trace" of the WebFOCUS code. Hint: It's not "BY HIGHEST 1".
BTW: This is going against Teradata.This message has been edited. Last edited by: Doug,
In FOCUS Since 1983 ~ from FOCUS to WebFOCUS. Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
May 24, 2010, 02:41 PM
Tom Flynn
APP APPENDPATH IBISAMP -RUN TABLE FILE GGSALES SUM MAX.DOLLARS MAX.UNITS END -EXIT
Then use SQL! SQL PASSTHRU - the answer to all of your "How can I replicate what SQL does?" type questions
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
May 31, 2010, 05:16 PM
Doug
quote:
Then use SQL! SQL PASSTHRU
... I know that one... But, our rule, basically, is not use QL Passthru... And the DBA's say to use "TOP 1"... That's why I asked... But, in the meantime and seeing that I only need to know if there are any records returned, I'm using "CNT.DST.PURCHASING_GROUP"
May 31, 2010, 07:28 PM
Doug
quote:
WHERE READLIMIT EQ 1
Equates to "SAMPLE 1" which reads the entire file then selects ONE random (sample) record from the answer set. This takes significantly longer then even a straight SUM.
May 31, 2010, 07:48 PM
Waz
Interesting....
So for Teradata it generates SAMPLE 1.
For Oracle it generates WHERE ROWNUM <=1 For SQL Server it generates SELECT TOP 1 For MS Access it does nothing FOCUS handles it.
I don't have access to any other databases.
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
June 01, 2010, 03:16 AM
Tony A
quote:
But, our rule, basically, is not use QL Passthru...
Then the pointy heads that make these rules should understand restrictive programming and ensure that best practice is designed for efficiency in data retrieval and not programming code.
Use the best tool for the job!
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
June 01, 2010, 09:53 AM
Francis Mariani
quote:
Then the pointy heads that make these rules should understand restrictive programming and ensure that best practice is designed for efficiency in data retrieval and not programming code.
This should be our new mantra.
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
June 01, 2010, 09:55 AM
Francis Mariani
When I run this (DB2 table):
TABLE FILE TIME_D
SUM
TIME_DIM_KEY
BY HIGHEST TIME_DIM_KEY
WHERE READLIMIT EQ 1
END
This is generated:
SELECT T1."TIME_DIM_KEY", SUM(T1."TIME_DIM_KEY") FROM
TIME_D T1 GROUP BY T1."TIME_DIM_KEY" ORDER BY
T1."TIME_DIM_KEY" DESC FETCH FIRST 1 ROW ONLY FOR FETCH 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