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

Doubt in Fetching from a Cursor.


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

New User


Joined: 21 Nov 2006
Posts: 50
Location: India

PostPosted: Mon Jan 22, 2007 5:31 pm
Reply with quote

The Cursor Declaration is

Declare Cur1 for
Select a,b from table 1


Fetch cur1 into :a1:x,:b1

whether the value of a in table1 is moved to a1 and x?
Back to top
View user's profile Send private message
ksathishkumar83

New User


Joined: 21 Nov 2006
Posts: 50
Location: India

PostPosted: Mon Jan 22, 2007 6:10 pm
Reply with quote

In the above Declaration, I want to move the value a from table 1 to to two host variables.

Help me with the exact Declaration...
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Jan 22, 2007 6:20 pm
Reply with quote

Try select a, a, b?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Jan 23, 2007 1:10 am
Reply with quote

as you used it in your cursor,
x is the indicator field (mostly for null value) and must be defined as S9(4) COMP.
a goes into :a1 and b into :b1
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Jan 23, 2007 1:11 am
Reply with quote

ksathishkumar83,

The way you have the fetch declared. Host variable ?x' is the null indicator for host variable ?a1?.

If column ?a? is not null, host variable ?x? will contain value 0, if column ?a? is null Host variable ?x? will contain -1. Also note that for this to not give you an error host variable ?x? must be defined as PIC S9(4) COMP.

If you want column ?a' to be populated in host variable ?a1? and ?x? you will need:

Code:

Declare Cur1 for
Select a,a,b from table 1

Fetch cur1 into :a1,:x,:b1


Note the addition of the ?,? between ':a1' and ': x'
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 Doubt about pl/1 (job offer) General Talk & Fun Stuff 5
No new posts Error while fetching the record from ... COBOL Programming 3
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
Search our Forums:

Back to Top