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
 

 

Cursor Declaration

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sunojsm
Warnings : 1

New User


Joined: 21 Jun 2004
Posts: 33
Location: Andorra

PostPosted: Wed Jun 08, 2011 3:24 pm    Post subject: Cursor Declaration
Reply with quote

Hi,

Consider the following example.

EXEC SQL
DECLARE CURSOR1 CURSOR FOR
SELECT
COL_ONE
COL_TWO,
COL_THREE,
COL_FOUR
COL_FIVE

FROM TABLE1

WHERE EMPSEC =:WS-EMPSEC

WITH UR
END-EXEC.

EXEC SQL
FETCH CURSOR1
INTO
:WS-COL-ONE
,:WS-COL-TWO
,:WS-COL-THREE
,:WS-COL-FOUR ---> DECIMAL(2,0)
,:WS-COL-FIVE ---> DECIMAL(3,0)
END-EXEC.


In above statements,you can see there is no comma between COL_FOUR and COL_FIVE in DECLARE.

I noted this while debugging the program which is there in production.

Is that declaration is valid ?
How it went fine with out showing any syntax error during precompilation process?

When i checked the value in WS-COL-FOUR it shows as 3 which was correct(value same as in table1),but in WS-COL-FIVE ,
it shows 000 instead of '2' which is the value in table1 for that column. Could anyone let me know what exactly happening here.
Back to top
View user's profile Send private message

GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Jun 08, 2011 4:38 pm    Post subject:
Reply with quote

select col1 col2 from
is the same as
select col1 as col2 from
it doesn't matter that col2 is also a column name.

I would have thought that the precompiler would say something like "number of columns in fetch are not equal to columns in cursor". but I'm not sure.
Back to top
View user's profile Send private message
sunojsm
Warnings : 1

New User


Joined: 21 Jun 2004
Posts: 33
Location: Andorra

PostPosted: Wed Jun 15, 2011 2:58 pm    Post subject: Reply to: Cursor Declaration
Reply with quote

hi GuyC,

The AS concept is correct and i didnt get any error or warning for this while binding or compiling. Still finding an answer for this.


Thanks
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 Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
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 Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


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