Page 1 of 1

Declaration Cursor location in DB2.

Posted: Mon May 26, 2014 5:14 pm
by zOSHelp
hi

Intwerviewer asked that, "Cusror can be declared in data division and procedure division. If declared in procedure division what care should be taken."

I did not really understand the question was not sure what exactly he wants to know, can someone here understands it and can guide.

Re: Declaration Cursor location in DB2.

Posted: Wed May 28, 2014 12:19 am
by Anuj Dhawan
Hello,

When you declare a cursor in the Procedure Division, make sure you don't issue an OPEN for it before you declare it -- because it's a procedure division, you can do so and pre-compiler and compiler won't complain about it though as a programmer you'd need to take care about it.

Hope this helps.

Re: Declaration Cursor location in DB2.

Posted: Wed May 28, 2014 12:22 am
by zprogrammer
I would reply the value of host variable needs to be populated before doing a open cursor irrespective of the where the cursor is declared and also ensure OPEN of cursor should not be done