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     [CLOSED] WebFOCUS to SQL Code for TOP 1
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] WebFOCUS to SQL Code for TOP 1
 Login/Join
 
Expert
posted
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
 
Posts: 3106 | Location: Tennessee, Nashville area | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
APP APPENDPATH IBISAMP
-RUN
TABLE FILE GGSALES
SUM
MAX.DOLLARS
MAX.UNITS
END
-EXIT


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1969 | Location: Centennial, CO | Registered: January 31, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
You could try WHERE READLIMIT EQ 1.


Waz...

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

 
Posts: 6275 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
quote:
SQL has a nice command, "TOP 1",
Then use SQL! SQL PASSTHRU - the answer to all of your "How can I replicate what SQL does?" type questions Smiler

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 
 
Posts: 5686 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Expert
posted Hide Post
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"
 
Posts: 3106 | Location: Tennessee, Nashville area | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
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.
 
Posts: 3106 | Location: Tennessee, Nashville area | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
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.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6275 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
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 
 
Posts: 5686 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Expert
posted Hide Post
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] WebFOCUS to SQL Code for TOP 1

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