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
How to get the ddl of a table in db2?
For a db2 column that is being defined as decimal (11, 2), discuss the cobol picture clause.
What is an instance in db2?
Mention the length of physical storage of the given data types of db2 – date, timestamp, time
How will you return the number of records in table?
Before you give the explain statement, what are the prerogatives?
My sql statement select avg(salary) from emp yields inaccurate results. Why?
What is bufferpool in db2?
What is db2 bind process?
How can you do the explain of a dynamic sql statement?
What is table space in db2?
What is role in db2?
What is scrollable cursor in db2?
What is the syntax for seeing the columns and data types of a table in the db2 database?
How can deadlocks be resolved?