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

Following a db2 update statement, what is the quickest way to compute the total number of updated rows?

624


What are bind parameters in db2?

611


Mention the various locks that are available in db2.

614


How to check last update on table in db2?

626


How do I connect my db2 database to ibm?

600






in my project..TEST is db2 8.1 version In PROD it is 7.1 if i do REORG in TEST.. can I use the same REORG jcl with out modification in PROD region (this is DB2 8.1 )? if not, what modification i need to do in my REORG control card?

1624


What is a system catalog table in db2?

586


If the cursor is kept open followed the issuing of commit, what is the procedure to leave the cursor that way?

698


How can we read records for specific member in CL? AND rpg?

229


How can the duplicate values be eliminated from db2 select?

623


Define buffer pool.

623


Which component is responsible for processing sql statements and selecting access paths?

662


How is a typical db2 batch pgm executed?

638


What is meant by explain?

660


How to check sequence on a table in db2?

598