Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us