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] How to loop n times based on the rows

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] How to loop n times based on the rows
 Login/Join
 
Guru
posted
Hi,

I have 2 queries and based on the number of rows in the 1st query, the 2nd query has to loop those many times.

Say in the 1st query if I have 6 rows, then my 2nd query has to loop 6 times.
Next time if the 1st query has 10 rows,then my 2nd query has to loop 10 times.

Iam new to this one and any help on how to do this would be highly appreciated!

Thanks a lot in advance!

Regards,
IP

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


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
 
Posts: 270 | Registered: October 30, 2014Report This Post
Master
posted Hide Post
http://forums.informationbuild...741063242#1741063242


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 668 | Location: Veghel, The Netherlands | Registered: February 16, 2010Report This Post
Virtuoso
posted Hide Post
If you only need to loop n times, the number of rows in the first query is in the &LINES variable.

Something like:
TABLE FILE CAR
SUM FST.COUNTRY
BY COUNTRY
END
-RUN

-REPEAT :LABEL FOR &I FROM 1 TO &LINES;
TABLE FILE CAR
SUM FST.CAR
END
-:LABEL


My guess is that you want to do something for each row in the first table though, in which case you're probably better served by a JOIN or a WHERE IN FILE.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Guru
posted Hide Post
Hi,

Thanks Dave and Wep5622 for the response and for the examples.


Actually I have 2 queries:
The 1st one would be like this :
select * from table1 ;
TABLE FILE table1
print
id
text noprint
on table hold as hld1
end
-run

Output : The result of the above query will be something like this :[Say it gives me 5 rows this time and next time if the data is more,then it would yield me 10 rows and so on]
100
200
300
400
500

This is my second query :
Select * from table2
where table2.text2 = text
and table2.id2 in (id);
end

Table file sqlout
print *
end

Now in the 2nd query, in the where condition, while Iam checking out for the id[where id2 in id] and this has to looped 5 times since we have got 5 rows in the 1st query.

Any thoughts/ideas on how to do this is greatly appreciated!
Thanks a lot in advance!

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
 
Posts: 270 | Registered: October 30, 2014Report This Post
Guru
posted Hide Post
TABLE FILE CAR
PRINT COUNTRY CAR MODEL
ON TABLE HOLD AS TEST
END
-RUN
TABLE FILE SYSCOLUM
PRINT NAME
WHERE TBNAME EQ 'TEST'
ON TABLE SAVE
END

-SET &howmany = &LINES;
TABLE FILE CAR
PRINT
-REPEAT :LP &howmany TIMES
-READ SAVE NOCLOSE &A.20
-TYPE &A
-SET &FIELDS=DECODE &A('COUNTRY' 'COUNTRY AS ''The Country''' 'CAR' 'CAR AS ''The Car''' 'MODEL' 'MODEL AS ''The Model''');
&FIELDS.EVAL
-:LP
END  


Its all about -READ & -REPEAT. All the best! It may help


-Rifaz

WebFOCUS 7.7.x and 8.x
 
Posts: 406 | Location: India | Registered: June 13, 2013Report This Post
Expert
posted Hide Post
Or:
-REPEAT :LABEL &LINES TIMES;
TABLE FILE CAR
SUM FST.CAR
END
-:LABEL
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 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] How to loop n times based on the rows

Copyright © 1996-2020 Information Builders