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

B37 abend during spufi?

980


How many databases are there?

590


What is iseries database?

597


How to check sequence on a table in db2?

600


Give a brief description of db2 isolation levels?

599






How does coalesce work?

585


Explain the function of data manager.

632


What is innodb buffer pool?

564


Explain about cursor stability?

621


What's The Percentage Free Space ?

770


What is the use of value function?

628


What is the use of with ur in db2?

615


What is db2 plan table?

622


What is the physical storage length of time data type?

673


How can deadlocks be resolved?

542