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

multiple rows fetch problem to host variables


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
swarna bathala

New User


Joined: 27 Apr 2009
Posts: 1
Location: hyderabad

PostPosted: Wed Dec 09, 2009 9:45 pm
Reply with quote

Hi,

When i used a select query in a COBOL program to fetch a value in to host variable, if there is a single value corresponding to that select criteria it fetches fine, but when ever there are multiple rows for that select criteria it is showing -811 sql code but also fetching the second qualified row into the host variable.
But when i used the same COBOL code in AIX it is not fetching any rows to the host variable.

Please let me know how mainframe COBOL is handling the code in this situation.

Thanks
Somasekhar Gajjala.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Dec 09, 2009 10:24 pm
Reply with quote

Hello,

If there is the possibility of returning more than one row, suggest you use a cursor. . .
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Dec 09, 2009 11:38 pm
Reply with quote

When you get a error sql code you should never depend on any host variables that may be returned.
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Thu Dec 10, 2009 12:53 pm
Reply with quote

Use the cursor,
Whenever you are dealing with more than one row then you should need to use the cursor,
singltone select query will fetch only the one row.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Dec 10, 2009 7:12 pm
Reply with quote

if your db2 vsn supports mult-row fetch, that is also an option where you do not need a cursor.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top