Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 965
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us