IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Select more than one row without using a cursor


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Thu Dec 27, 2007 6:15 pm
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
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Dec 27, 2007 6:17 pm
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: 1042
Location: Richmond, Virginia

PostPosted: Thu Dec 27, 2007 6:36 pm
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: 295
Location: Singapore

PostPosted: Thu Dec 27, 2007 6:43 pm
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: 295
Location: Singapore

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

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

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: 355
Location: New York

PostPosted: Fri Dec 28, 2007 2:57 pm
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

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Wed Jan 23, 2008 2:29 pm
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: 165
Location: Bangalore

PostPosted: Wed Jan 23, 2008 4:26 pm
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: 29

PostPosted: Fri Jan 25, 2008 12:18 pm
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
  ;


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
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Dynamically pass table name to a sele... DB2 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts How can I select certain file dependi... JCL & VSAM 12
Search our Forums:

Back to Top