View previous topic :: View next topic
|
Author |
Message |
sen_1983us
New User
Joined: 21 May 2005 Posts: 21 Location: Hyderabad
|
|
|
|
I will have multiple rows fetched from a query , i need to write all the records in to a file/ print as report.Someone help me how to do this. |
|
Back to top |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
Hi,
Follow below steps
1. Create a cursor at the begining of the program. Open the cursor.
2. Repeat below steps until you reach end of the cursor i.e. SQLCODE = +100.
-- Fetch Cursor into host variables
-- Move Host variable data to File variable or Report Variables
-- WRITE FILE or Report
3. Close Cursor and Close File or Report.
Thanks,
Reddy |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
@ovreddy : I guess you missed the part : multirow ?
@sen: pseudo cobol:
Code: |
open cursor
perform until sqlcode not = 0
fetch next rowset for 100 rows
move sqlerrd(3) to nrow-fetched
perform varying ix from 1 by 1 until ix > nrow-fetched
move host-var1 (ix) to output-var1
move host-var2 (ix) to output-var2
write
end-perform
end-perform
close cursor |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I guess you missed the part : multirow ? |
Quote: |
1. Create a cursor at the begining of the program. Open the cursor.
2. Repeat below steps until you reach end of the cursor i.e. SQLCODE = +100. |
Would this not handle multirow? Seems like lots of the code here does exactly this to handle multirow selection. . .
Actually, when the code was written, this was the only to select multiple rows for a predicate. . . |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
fetching 1 row multiple times <> fetching multiple rows
fetching multiple rows is not the same as selecting multiple rows.
It could be that the poster asks for solution of ovreddy, but then he has phrased his question wrong. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Guy,
Possibly we have read this differently:
Quote: |
I will have multiple rows fetched from a query , i need to write all the records in to a file/ print as report |
I don't see where "fetching 1 row multiple times" is mentioned in the original request |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
is it "multiple-rows fetched" or "multiple rows-fetched" ?
my solution was for "multiple-rows fetched".
Any way now TS has both solutions, and hopefully he can decides whihc one he needs. |
|
Back to top |
|
|
prashanth1
New User
Joined: 27 Sep 2006 Posts: 47 Location: Hyderabad
|
|
|
|
In perfromance aspect multple-rows fetch better than multiple rows-fetch.
But there are some limitations in multiple-rows fetch. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
where "fetching 1 row multiple times" is mentioned |
And re-reading this again today, i see where i misread. . .
What i read (although mistakenly) was to read the same row (i.e. 1 row) multiple times. . .
I'll try to do better
d |
|
Back to top |
|
|
|