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

Declare cursor and fetch cursor select field mismatch


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

Active User


Joined: 04 Oct 2006
Posts: 118
Location: NJ, USA

PostPosted: Wed Jan 10, 2007 10:01 pm
Reply with quote

Hi,
I have a program which has a Cursor with 2 columns declared, but only one field is fetched during FETCH cursor.
the code is running fine in produciton.

The Declare stmnt:
Code:
DECLARE ACCOUNT-CURSOR CURSOR FOR 
    SELECT                         
          AC_XTNL_NO,             
          AC_XTNLNO_END_CDT       
    FROM 


The fetch stmnt:
Code:
EXEC SQL               
   FETCH ACCOUNT-CURSOR
   INTO :CRF-AC-XTNL-NO
END-EXEC.               


Why this is not giving any error?. Is it because the last field being missed?
My understanding so far - the number of columns declared in the cursor should be fetched.

Can anyone clarify me please.

Thanks,
Viji
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Jan 10, 2007 10:47 pm
Reply with quote

vijikesavan wrote:
The Declare stmnt:
Code:
DECLARE ACCOUNT-CURSOR CURSOR FOR 
    SELECT                         
          AC_XTNL_NO,             
          AC_XTNLNO_END_CDT       
    FROM 
The fetch stmnt:
Code:
EXEC SQL               
   FETCH ACCOUNT-CURSOR
   INTO :CRF-AC-XTNL-NO
END-EXEC.               
Why this is not giving any error?. Is it because the last field being missed?
My understanding so far - the number of columns declared in the cursor should be fetched.
I'd be guessing that DB2 is being nice to you since you only asked for the one column. I'd think you would get both if the fetch had two host variables to put both in.....
Just guessing.... icon_smile.gif
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jan 11, 2007 11:39 am
Reply with quote

HI
this wont give any error but the SQLWARN3 field of SQLCA will be set to W ..tht is a warning ....
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts SELECT from data change table DB2 5
Search our Forums:

Back to Top