Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ 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 -> Mainframe Interview Questions
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    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

stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
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

Active Member


Joined: 31 Oct 2006
Posts: 962
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: 295
Location: Singapore

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: 295
Location: Singapore

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

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

New User


Joined: 24 Dec 2005
Posts: 52
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: 165
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: 29

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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us