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     storing value of one sql in report variable and passing to another sql

Read-Only Read-Only Topic
Go
Search
Notify
Tools
storing value of one sql in report variable and passing to another sql
 Login/Join
 
Member
posted
I am showing multiple tables one-by-one in a pdf file. Each table having single row of record and is generating through one separate sql, and each next sql uses column value of previous sql(s).

How to store column values of each sql into report level variables so that i can use them anywhere or pass them into another sqls.

Please provide a code example (may be of CAR Table) to perform this task.



WebFOCUS Versions using 7.1; Platform: Windows XP; Output Format: PDF.
 
Posts: 16 | Registered: September 07, 2007Report This Post
Gold member
posted Hide Post
You would need to hold the query results into a temporary file, then use a -READ to get the values into a variable.

TABLE FILE CAR
PRINT COUNTRY
IF COUNTRY EQ 'ENGLAND'
ON TABLE HOLD
END
-RUN
-READ HOLD, &COUNTRY
TABLE FILE CAR
HEADING
"SALES FOR &COUNTRY "
PRINT SALES
BY CAR
BY MODEL
END



Windows: WF 7.6.2: SQL Server 2008 R2
 
Posts: 86 | Location: Chicago | Registered: August 03, 2007Report This Post
Virtuoso
posted Hide Post
Abhi

What do you mean with this, do you want to join tables, and create report on that?

Or do you mean storing some data in an alpha hold file and read them into amper values, which can be used either to be displayed or to to be used in the second request.

Or do you want to create a report from which you can drill down into an other lower leveled report.

(please provide code example from what you have now, if possible on the CAR table or one of the other example tables)




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Member
posted Hide Post
Abhi,

Here is a sample from our code. Not using the CAR file though. I hope you can figure it out from this. This "program" takes a variable from a input screen i.e. &CrReasCd and retreives the description of that credit reason into 2 variables that can then be used in the fex.

Good luck - Marie


SQL SQLINF
SELECT cr_reason_nm::CHAR(30) AS desc_only
, (TRIM(cr_reason_nm) || ' (' || LPAD(cr_reason_cd, 2, '0') || ')')::CHAR(40)
AS desc_and_num
FROM credit_reason_05
WHERE cr_reason_cd = &CrReasCd
;
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS TMPFILEA FORMAT FOCUS
END
-IF &RETCODE NE 0 GOTO IncSqlErr;
-IF &LINES EQ 0 GOTO NotFound;
-RUN
TABLE FILE TMPFILEA
PRINT
desc_only
desc_and_num
ON TABLE HOLD AS TMPFILEB FORMAT ALPHA
END
-RUN
-READ TMPFILEB &OUT_DescOnly.A30. &OUT_DescAndNum.A40.
-RUN
END
-GOTO EndInc;
-***
-NotFound
-SET &OUT_DescOnly = 'Unknown Credit Reason ' | &CrReasCd;
-SET &OUT_DescAndNum = 'Unknown Credit Reason (' | &CrReasCd | ')';
-GOTO EndInc;
-***
-IncSqlErr
&INC_SQLERROR.EVAL
-EndInc
-TYPE OUT_DescOnly = &OUT_DescOnly
-TYPE OUT_DescAndNum = &OUT_DescAndNum


WebFOCUS 7.1.6 on Win 2K SP2 - Self Service, Informix SQL Passthru
 
Posts: 14 | Location: Seattle, WA | Registered: June 15, 2005Report This Post
Member
posted Hide Post
Thanks for code help.
But Gizmo, your code prints second table content, while i want to print both tables one-by-one.
Marie, your code reachs very near what I want but still it has same problem as with Gizmo's example, also I don't want to fix length of column values as it is padding unnecessary 0's to variable values.

Frank, your 2nd guess is somewhat correct but If I hold first table in ALPHA, then how can i print that table also?

Ex:

SQL1: SELECT colA1, colA2, ColA3 FROM Tab1 WHERE colA1 = '&INPUT1' <-#INPUT VALUE FROM USER SCREEN#

SQL2: SELECT colB1, colB2 FROM Tab2 WHERE colB1 = '# colA1 value of SQL1 #'

SQL3: SELECT colC1, colC2, colC3, colC4 FROM Tab3 Where colC1 = '# colA1 value #' AND colC2 = '# colB2 value #'

o/p:

colA1 colA2 colA3
----- ----- -----
5 AAAA PPPP

colB1 colB2
----- -----
5 BCODE

colC1 colC2 colC3 colC4
----- ----- ----- -----
5 BCODE QTY1 HRS1

I think now my question is clear. I am printing all 3 tables. I dont know whether Amper Variable can do or DEFINE/COMPUTE can do it? In-place of SQL, CAR table can be used for example.

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



WebFOCUS Versions using 7.1; Platform: Windows XP; Output Format: PDF.
 
Posts: 16 | Registered: September 07, 2007Report This Post
Member
posted Hide Post
Do you really need your result into an amper variable? Otherwise, you can create a temp table and select your first SQL into that and then use that in a sub-select in your second SQL and so on. You cannot, at least not using INFORMIX like we do, "SELECT ... INTO TEMP xxx", you have to create the temp table first and then select into it.

As far as the fixed length goes, you can save a delimted file instead and use the delimited file -READ syntax instead (see help in DevStudio for examples of different -READ syntax.

Marie


WebFOCUS 7.1.6 on Win 2K SP2 - Self Service, Informix SQL Passthru
 
Posts: 14 | Location: Seattle, WA | Registered: June 15, 2005Report This Post
Virtuoso
posted Hide Post
Abhi

take a look at this discussion, it's more ore less the same as yours

https://forums.informationbuilders.com/eve/forums/a/tpc/...1057331/m/5361030942

And it's running today also.
It might be helpful for you to get an idea of how this can be done.
Maybe it would be a good investment to take some basic training on this software, I do not know where you live, but ask your manager for it.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Member
posted Hide Post
The IBI forum is the place where others know more or already faced such problems and may know the solution in bettre way. Thats why most people as me like to come here.

When anybody comes to IBI forums if he/she could not find solution from Webfocus Online Help Document or any other site or other close sources like manager or training. I cannot rate myself in this Tool perfectly but for every single problem why need to go for one or two days training!!!

I will try to post the simple solution for this problem as soon as it get resolved. I appreciate each member to suggest their ways to solve any problem and make this forum best useful.

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



WebFOCUS Versions using 7.1; Platform: Windows XP; Output Format: PDF.
 
Posts: 16 | Registered: September 07, 2007Report This Post
Member
posted Hide Post
Hey Marie!

Thanks for the idea!
I am displaying 11 tables(each having single row), generated through 11 different SQLs, consecutively in single PDF file. The later 8 SQLs are using input from column value of first 3 SQLs. I made 3 temp tables using first 3 SQLs and stored the values in amper variables. Then I printed those 3 files and then rest 8. Now I am able to use these variables smoothly anywhere for any SQL.

I know how to create amper variable before, but your idea of temp table handled this requirement well.

Have a nice day!



WebFOCUS Versions using 7.1; Platform: Windows XP; Output Format: PDF.
 
Posts: 16 | Registered: September 07, 2007Report 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     storing value of one sql in report variable and passing to another sql

Copyright © 1996-2020 Information Builders