Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Select more than one row without using a cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions
Author Message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 23
Location: Bangalore

PostPosted: Thu Dec 27, 2007 6:15 pm    Post subject: Select more than one row without using a cursor
Reply with quote

Interview Qt :

How can I select more than one row without using a cursor in cobol-db2 batch program , using embedded sql.
Back to top
View user's profile Send private message
References
PostPosted: Thu Dec 27, 2007 6:15 pm    Post subject: Re: Select more than one row without using a cursor Reply with quote

stodolas

Senior Member


Joined: 13 Jun 2007
Posts: 647
Location: Wisconsin

PostPosted: Thu Dec 27, 2007 6:17 pm    Post subject:
Reply with quote

You can't. Unless you run a new select for each row with a where that will only return one row.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 498
Location: Richmond, Virginia

PostPosted: Thu Dec 27, 2007 6:36 pm    Post subject:
Reply with quote

COBOL allows selection into an array.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 164
Location: Pune

PostPosted: Thu Dec 27, 2007 6:43 pm    Post subject:
Reply with quote

I suppose, there is some MULTI-ROW fetch cursor option in DB2V8 and V9, I haven't tried though.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 164
Location: Pune

PostPosted: Thu Dec 27, 2007 7:11 pm    Post subject:
Reply with quote

The following link contains an example of multi-row fetch.

http://blogs.ittoolbox.com/database/db2zos/archives/kewl-db2-for-zos-version-8-feature-part-2a-multirow-insert-fetch-7377
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 275
Location: Pune, India

PostPosted: Fri Dec 28, 2007 2:57 pm    Post subject:
Reply with quote

Put query in Perform loop and move the values into array.
Back to top
View user's profile Send private message
priyamnavada

Active User


Joined: 24 Dec 2005
Posts: 57
Location: hyderabad

PostPosted: Wed Jan 23, 2008 2:29 pm    Post subject:
Reply with quote

perform the select query till the rows are not found. For each select place the data into the table.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 168
Location: Bangalore

PostPosted: Wed Jan 23, 2008 4:26 pm    Post subject:
Reply with quote

we cant select multiple row without using cursors in DB2-COBOL batch programs.
Back to top
View user's profile Send private message
vkphani

New User


Joined: 29 Oct 2003
Posts: 30

PostPosted: Fri Jan 25, 2008 12:18 pm    Post subject:
Reply with quote

If you have db2 version 7 then you can use the following query to get N rows of a table.

Code:
SELECT *
  FROM TABLE
  FETCH FIRST N ROWS ONLY
  ;


http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/4.4.7?SHELF=&DT=20010718164132
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions All times are GMT + 6 Hours
Page 1 of 1