Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Doubt in Fetching from a Cursor.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Doubt in Fetching from a Cursor.
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    Post subject: Re: Doubt in Fetching from a Cursor.
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: 3158
Location: Tucson AZ

PostPosted: Mon Jan 22, 2007 6:20 pm    Post subject:
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: 1226
Location: Israel

PostPosted: Tue Jan 23, 2007 1:10 am    Post subject: Re: Doubt in Fetching from a Cursor.
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    Post subject: Re: Doubt in Fetching from a Cursor.
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Doubt in MFS abdulrafi IMS DB/DC 2 Fri Oct 21, 2016 3:09 pm
No new posts Can we use OPTIMIZE FOR 1 ROWS for fe... cvijay784 DB2 1 Fri Aug 05, 2016 11:56 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us