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

mutiple select in DB2.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ursprasanna
Warnings : 2

New User


Joined: 15 May 2006
Posts: 20
Location: chennai

PostPosted: Mon May 22, 2006 4:59 pm
Reply with quote

When know that If there is a multiple row select for a select statement then , the select ends up with a sqlabend.

By using cursor we can handle this problem.

I would like to know whether this problem can be handled with out using cursor .

If so how??

Thanks,
Prasanna Subramaniam.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Mon May 22, 2006 6:01 pm
Reply with quote

Hi,

There is two approch.
1) use the cursor
2) stregthentr ur where clause so that u will get only 1 row.

Correction r welcome
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Mon May 22, 2006 6:42 pm
Reply with quote

Prasanna
It all depends on what u are trying to do with your SELECT Stmt.
1) If you want to fetch all rows no matter what - CURSOR is needed.
2) If you know that all the rows returned are dups and wish to fetch just a single row. You could use SELECT DISTINCT, or FETCH FIRST 1 ROWS ONLY.
3) If all you wanna know is, if the query returns any rows, you could check for the SQLCODE after the query for -811.
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 -> DB2

 


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