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     [CLOSED] WebFOCUS to SQL Code for TOP 1

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[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: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report 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: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report 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.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report 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: 5694 | Location: United Kingdom | Registered: April 08, 2004Report 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: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report 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: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report 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.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report 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: 5694 | Location: United Kingdom | Registered: April 08, 2004Report 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, 2005Report 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, 2005Report 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     [CLOSED] WebFOCUS to SQL Code for TOP 1

Copyright © 1996-2020 Information Builders