Cursors can be declared in both working-storage & procedure
division, Agreed.
But is there any difference? If could you please suggest
what is the difference.
TIA

Answer Posted / bud gobbel

Actually, there is a reason for declaring the cursor in the Procedure Division, however, it is slight.

In CICS programs, the communications area (CA) is passed via the linkage section. If a cursor WHERE clause is predicated on a field in the CA area, then to avoid using a working storage variable and a MOVE statement prior to the opening of the cursor, you should code the cursor declaration in the Procedure Division, prior to the opening logic, etc.

If you don't mind using extra variables, and coding the required MOVE statements, then keep your cursor dec in WS.

In your DB2 pre-compiler, you can test this logic. Put the cursor above the linkage section, and try to use a field in the linkage section as a host variable in the where clause.

Then move it to the very early part of the Procedure Division. The pre-compiler will then be happy.

Good Luck!

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is lock escalation in db2?

574


How does cobol compile db2 program?

609


What are the rules for db2 programming?

643


What is query_cache_limit?

545


How do you concatenate the firstname and lastname from emp table to give a complete name?

603






What is package in db2 mainframe?

559


How do I copy a table in db2?

575


What is load replace in db2?

560


Is ibm db2 open source?

586


Which are the db2 tools to protect integrity of the database?

692


How to get the ddl of a table in db2?

679


What is blu acceleration in db2?

608


My sql statement select avg(salary) from emp yields inaccurate results. Why?

643


How do you eliminate duplicate values in db2?

687


What is a page in db2?

610