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
 

 

Declare cursor and fetch cursor select field mismatch

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Declare cursor and fetch cursor select field mismatch
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: 3158
Location: Tucson AZ

PostPosted: Wed Jan 10, 2007 10:47 pm    Post subject: Re: Declare cursor and fetch cursor select field mismatch
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    Post subject:
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    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 SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm


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