473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

multirow fetch with embedded SQL

Is there a way to do a multi-row fetch in to a COBOL table with DB2/LUW?
Apparently the following is supported in z/OS, but not LUW (or at least I
couldn't get it to work):

WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC
EXEC SQL
BEGIN DECLARE SECTION
END-EXEC
01 table2-area.
05 table2-entry.
10 t2-name pic x(30) occurs 100.
10 t2-dept pic x(04) occurs 100.
EXEC SQL
END DECLARE SECTION
END-EXEC
EXEC SQL
DECLARE CURSOR-X CURSOR FOR
select name, dept
from test.table2
where name in (select distinct name from test.table1)
END-EXEC.
.......
PROCEDURE....
exec sql
FETCH NEXT CURSOR-X
into :T2-NAME, :T2-DEPT
for 100 rows
end-exec
Frank

Jan 31 '08 #1
7 6784

You need to open the cursor before fetching.

In procedure division:

exec sql
open cursor-x
end-exec

perform until sqlcode not = zero

exec sql
fetch cursor-x
into :T2-NAME, :T2-DEPT
end-exec

* Do something with the data.

end-perform.

exec sql
close cursor-x
end-exec

While stranded on information super highway Frank Swarbrick wrote:
Is there a way to do a multi-row fetch in to a COBOL table with DB2/LUW?
Apparently the following is supported in z/OS, but not LUW (or at least I
couldn't get it to work):

WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC
EXEC SQL
BEGIN DECLARE SECTION
END-EXEC
01 table2-area.
05 table2-entry.
10 t2-name pic x(30) occurs 100.
10 t2-dept pic x(04) occurs 100.
EXEC SQL
END DECLARE SECTION
END-EXEC
EXEC SQL
DECLARE CURSOR-X CURSOR FOR
select name, dept
from test.table2
where name in (select distinct name from test.table1)
END-EXEC.
......
PROCEDURE....
exec sql
FETCH NEXT CURSOR-X
into :T2-NAME, :T2-DEPT
for 100 rows
end-exec
Frank
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Jan 31 '08 #2
Well, yes, but that was not the question. (I guess my question was a bit
ambiguous. Sorry.)

A 'multi-row' fetch (not sure if that is the correct name) appears to allow
you to declare a COBOL table in working storage, and do a single FETCH
statement to populate it with a multi-row result set.

Apparently this is supported in DB2 for z/OS, as in the example I gave. Not
having access to DB2 for z/OS myself I can't test it, but it is stated in
the manual, and a z/OS programmer is the one who I got the example from.

Personally, I'm fairly happy with using OPEN FETCH/FETCH/FETCH CLOSE, but
there's an argument on comp.lang.cobol that retrieving multiple rows with a
single FETCH is show how 'better' or 'more modern' or some such thing! :-)

Frank

n 1/31/2008 at 12:47 PM, in message <fn**********@new7.xnet.com>, Hemant
Shah<sh**@typhoon.xnet.comwrote:
You need to open the cursor before fetching.

In procedure division:

exec sql
open cursor-x
end-exec

perform until sqlcode not = zero

exec sql
fetch cursor-x
into :T2-NAME, :T2-DEPT
end-exec

* Do something with the data.

end-perform.

exec sql
close cursor-x
end-exec

While stranded on information super highway Frank Swarbrick wrote:
>Is there a way to do a multi-row fetch in to a COBOL table with DB2/LUW?
>Apparently the following is supported in z/OS, but not LUW (or at least
I
>couldn't get it to work):

WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC
EXEC SQL
BEGIN DECLARE SECTION
END-EXEC
01 table2-area.
05 table2-entry.
10 t2-name pic x(30) occurs 100.
10 t2-dept pic x(04) occurs 100.
EXEC SQL
END DECLARE SECTION
END-EXEC
EXEC SQL
DECLARE CURSOR-X CURSOR FOR
select name, dept
from test.table2
where name in (select distinct name from test.table1)
END-EXEC.
......
PROCEDURE....
exec sql
FETCH NEXT CURSOR-X
into :T2-NAME, :T2-DEPT
for 100 rows
end-exec
Frank
Feb 1 '08 #3
This support hasn't been added yet.
The same is true for INSERT and MERGE.
DB2 for zOS is leading the charge here.

First time is see the requirement against DB2 for LUW.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 1 '08 #4
Serge Rielau wrote:
This support hasn't been added yet.
The same is true for INSERT and MERGE.
DB2 for zOS is leading the charge here.

First time is see the requirement against DB2 for LUW.
DB2 for i5/OS has supported the multiple-row-fetch clause for a number
of releases (aka "FOR n ROWS"):

http://publib.boulder.ibm.com/infoce...afzmstfets.htm
http://publib.boulder.ibm.com/infoce...afzmstfets.htm

--
Karl Hanson
Feb 1 '08 #5
>>On 1/31/2008 at 6:26 PM, in message
<60*************@mid.individual.net>,
Serge Rielau<sr*****@ca.ibm.comwrote:
This support hasn't been added yet.
The same is true for INSERT and MERGE.
DB2 for zOS is leading the charge here.

First time is see the requirement against DB2 for LUW.
Do you mean that there *is* a requirement, or that I should submit one?

Thanks,
Frank

Feb 1 '08 #6
Frank Swarbrick wrote:
>>>On 1/31/2008 at 6:26 PM, in message
<60*************@mid.individual.net>,
Serge Rielau<sr*****@ca.ibm.comwrote:
>This support hasn't been added yet.
The same is true for INSERT and MERGE.
DB2 for zOS is leading the charge here.

First time is see the requirement against DB2 for LUW.

Do you mean that there *is* a requirement, or that I should submit one?
You should submit it. Obviously it exists (and was addressed) for DB2
for i5/OS and zOS.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 1 '08 #7
>>On 2/1/2008 at 11:20 AM, in message
<60*************@mid.individual.net>,
Serge Rielau<sr*****@ca.ibm.comwrote:
Frank Swarbrick wrote:
>>>>On 1/31/2008 at 6:26 PM, in message
<60*************@mid.individual.net>,
Serge Rielau<sr*****@ca.ibm.comwrote:
>>This support hasn't been added yet.
The same is true for INSERT and MERGE.
DB2 for zOS is leading the charge here.

First time is see the requirement against DB2 for LUW.

Do you mean that there *is* a requirement, or that I should submit one?
You should submit it. Obviously it exists (and was addressed) for DB2
for i5/OS and zOS.
Sounds good.
Thanks,
Frank
Feb 4 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: yawnmoth | last post by:
i've written a php script that generates images dynamically, via the GD library. i now want to detect whether or not the image is embedded within a homepage, or is being viewed by itself. at...
8
by: Evan Smith | last post by:
During a routine performance check using an event monitor, I discovered a class of query whose performance has me baffled. The monitor captured: SELECT * FROM EWM_CASE fetch first 1 rows only...
9
by: Wayne | last post by:
Is there a way to stop the default action of a multirow tab control whereby the row with focus moves to the front of the tabs? I find this behaviour annoying and confusing to the user and am at a...
25
by: VictorReinhart | last post by:
Hi, I am intersted in trying to reduce the cost of C# development, by reducing the number of lines of code. In my opinion, as a business developer, the biggest opportunity to reduce the number of...
8
by: Andreas Zita | last post by:
Hi Im creating my first 2.0 site and I cant find the Build Action property? I want to embedd an image-file in my site-assembly but I don't know how? In 1.1 I could set Build Action to Embedded...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
0
by: garethrichardadams | last post by:
Hello all, I've added a font to my project and set it to "Embedded Resource". I load the font into a global PrivateFontCollection. (InitCustomFont - shown below) I then set the font of a...
0
by: loken0673 | last post by:
Hello All I want to Split multirow resultset to single row, multicolumn resultset my table is ProfileDetail(ProfileId bigint, PropertyId bigint PropertyValue nvarchar(400)) Table data : ...
1
by: edwald | last post by:
I have very little experience with DB2, but am writing a simple C program, with embedded SQL, that has among other things EXEC SQL BEGIN DECLARE SECTION; double F; /*...*/ EXEC SQL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.