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

Problem with Defining Cursor


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

New User


Joined: 06 Apr 2005
Posts: 30
Location: visakhapatnam

PostPosted: Wed Jul 19, 2006 6:18 pm
Reply with quote

If the table consists of more fields can we give

EXEC SQL
DECLARE cursor-name CURSOR FOR
SELECT *
FROM table-name
WHERE search-condition
END-EXEC.
Back to top
View user's profile Send private message
cmbb

New User


Joined: 01 Feb 2006
Posts: 4

PostPosted: Wed Jul 19, 2006 7:29 pm
Reply with quote

You can use it. When you fetch this cursor, you must read into the level 01 of the copy with the host variable.
This solution has some problems like, when you change the table, adding or removing fields, you must change the copy and recompile the program.
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Thu Jul 20, 2006 11:27 am
Reply with quote

Quote:
If the table consists of more fields can we give


What do you mean by this? Tables use to have many fields !!

Or did you mean, if the SELECT query returns more rows (than one), can the CURSOR be used?

Yes you can, and that's what CURSORs are meant for! And your program should have a loop to process/handle all rows returned by the CURSOR.


Cheers, Twissi.
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Defining a struct PL/I & Assembler 3
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
Search our Forums:

Back to Top