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] SQL code question into WF

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] SQL code question into WF
 Login/Join
 
Master
posted
Hi

I have this sample SQL code. I am not sure how to use this variable in WebFOCUS code. Can someone let me know how to use it?

  
SELECT count(*) INTO :count1
FROM sales
WHERE sale_id = 1;
'received_count1'

SELECT count(*) INTO :count2
FROM sales
WHERE sale_id = 2;
'received_count2'



I have multiple queries like this. If its a group of fields, I use SQLOUT to push them into hold file. But how do I use a value coming out of these queries? I am not sure if value is stored in COUNT1 or RECEIVED_COUNT1

Thank you

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


8.1.05
HTML,PDF,EXL2K, Active, All
 
Posts: 484 | Registered: February 03, 2009Report This Post
Virtuoso
posted Hide Post
I think it's not quite possible to do this in one go within webfocus.
Alternative would be to get the individual counts, store them in holds and -READ the holds into the corresponding &vars.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Master
posted Hide Post
Thanks Gamp, thats the only way I have in mind.


8.1.05
HTML,PDF,EXL2K, Active, All
 
Posts: 484 | Registered: February 03, 2009Report This Post
Virtuoso
posted Hide Post
If all of your counts come from the very same table, you could:

SQL [your_engine]
SELECT count(case when sale_id = 1 then 1 else null end) as RECEIVED_COUNT1,
       count(case when sale_id = 2 then 1 else null end) as RECEIVED_COUNT2,
       count(case when sale_id = 3 then 1 else null end) as RECEIVED_COUNT3
  FROM sales
WHERE sale_id IN (1,2,3)
;
TABLE ON TABLE HOLD AS HCOUNTS
END
-RUN

-READFILE HCOUNTS

-TYPE &RECEIVED_COUNT1
-TYPE &RECEIVED_COUNT2
-TYPE &RECEIVED_COUNT3



Though it is not exactly an answer to your original question, it is a bit more efficient way to get many of the results you need with a single pass over your SALES table and one single data fetch from the database.

Hope this helps.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Master
posted Hide Post
The INTO keyword typically means it's loading a table on the RDBMS. I'm guessing that :tablename is some dialect of this (SQL Server is #tablename). Maybe DB2?

Temp tables and global temp tables are the RDBMS conceptual answer to hold files.

Refer:
http://www.simple-talk.com/sql...ables-in-sql-server/

http://publib.boulder.ibm.com/...c/admin/r0000994.htm


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Virtuoso
posted Hide Post
Hi ABT, his original SQL is not loading data into a table. It is actually reading a single value (one row, one field) from it and placing the result in a client "variable" (in this case, :var looks like the syntax used by Oracle to refer to bind variables).

So, to achieve a similar functionality in WebFOCUS, that is, placing the results of single-row/field query in a Dialogue Manager variable one has to HOLD the results of the query and -READ from them as GamP had already suggested.

What I was trying to illustrate was how to get those many values in a single round-trip to the database as opposed to getting many individual ones with tiny HOLD files here and there.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Master
posted Hide Post
quote:
Originally posted by njsden:
Hi ABT, his original SQL is not loading data into a table. It is actually reading a single value (one row, one field) from it and placing the result in a client "variable" (in this case, :var looks like the syntax used by Oracle to refer to bind variables).


I don't usually appreciate people correcting me over nits and nats, but in this case I was way off. Thanks for setting the record straight.

;-)

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report 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] SQL code question into WF

Copyright © 1996-2020 Information Builders