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 the difference between cursor and select statement?

613


Explain about dbrm.

607


What is db2?

739


How would you find out the total number of rows in a db2 table?

576


How can you classify the locks in db2?

632






Which command is used to connect to a database in DB2 ? Give the Syntax.

599


Can one database have multiple instances?

580


What is rebind in db2?

574


What r the comman abends in db2, jcl and cobol???????

1818


How to find the number of rows in a db2 table?

644


What is null indicator in db2?

602


What is drop table?

582


Where can you declare a cursor in a cobol-db2 program?

602


What is a db2 collection?

603


Explain packages.

660