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 / sam

yes there sre diffrence.
If we declare cursor in working storage section then it is
called as static cursor without parameters from cobol.

If we declare cursor in procedure division then we can use
COBOL variables as parameters to the cursor. See the
examples for both the cases...

Eg: STATIC CURSOR

WORKING-STORAGE SECTION.
01 HV-EMPNO PIC 9(4) value 7934.
EXEC SQL
DEFINE C1 CURSOR FOR SELECT * FROM EMP WHERE EMPNO=HV-EMPNO
END-EXEC.

In the above case EMPNO is static. We cannot move a value
or read a value in to empno, because it is in working
storage section.

DYNAMIC CURSOR:

PROCEDURE DIVISION.
ACCEPT HV-EMPNO.
EXEC SQL
DECLARE C1 CURSOR FOR SELECT * FROM EMP WHERE EMPNO=:HV-
EMPNO
END-EXEC.

In the above example we can read EMPNO from another table
or file or we can take it from user. Now cursor becomes
dynamic.

I hope now its clear for you. If you need more information
let me know.

Is This Answer Correct ?    6 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the syntax for creating a table in the db2 database?

628


Is the primary key a clustered index?

611


Before you give the explain statement, what are the prerogatives?

581


How to find schema of a table in db2?

572


Can we delete records from view?

566






How to restart a DB2 program?

1365


Is db2 a database?

574


What are sqlcodes –803,-805, -811, -818,-904,-911,-913,-101, +100?

714


What is consistency token in db2?

640


How can you count the number of rows from a table tab?

637


On which levels locks can be applied?

659


Hi, i would like to start a new carrier in DB2 DBA.Which and what all step should i have to take..?

2688


What is the difference between using bind () and rebind () methods of naming class?

795


Mention data types used in db2 ?

679


What is difference between isnull and coalesce?

620