473,762 Members | 8,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6835

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**********@n ew7.xnet.com>, Hemant
Shah<sh**@typho on.xnet.comwrot e:
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.individua l.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.individua l.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.individua l.net>,
Serge Rielau<sr*****@ ca.ibm.comwrote :
Frank Swarbrick wrote:
>>>>On 1/31/2008 at 6:26 PM, in message
<60*********** **@mid.individu al.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
2129
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 first, i thought that whether or not HTTP_SERVER_VARS was set, that it would mean that the image was embedded, but that's not necessarily the case, as it will also be set if it's just linked to from the webpage. so, any ideas?
8
21128
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 It took 14 seconds of CPU time to execute. After looking up the documentation on the FETCH FIRST notation I find "Limiting the result table to the first integer rows can improve performance. The database
9
6781
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 loss as to why MS has designed their tab controls like this.
25
11139
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 lines of code is in database access. My reality is that I use relational databases a lot. Other constructs, such as flat files, Web Services, arrays, etc I don't use very much. My data is stored on relational databases. I think that's...
8
6080
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 Resource in the properties pane but this doesn't seem to be available any more??? /Andreas
7
3537
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 performs MySQL queries to a database. These queries are performed at regular intervals. Basically it is looking for fields that match certain criterias. Such fields are not present at all time. When the program finds such field, it then takes
0
6500
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 label to be equal to the custom font (SetCustomFont - shown below)
0
1650
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 : ProfileId PropertyId PropertyValue 97 1 lokendra
1
2144
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 END DECLARE SECTION; ...
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9927
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3914
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.