How to Update a Cursor using COBOL
- 1). Type "Edit" at the ">" z/OS system management console prompt and press the "Enter" key to edit your COBOL program.
- 2). Add the following code after the "EXEC SQL" section of your program:
EXEC SQL DECLARE CURSOR2
CURSOR FOR
SELECT PARTNAME, SALESPRICE
FROM PURCHDB.PARTS
WHERE PARTNUMBER BETWEEN :LOWVALUE AND :HIGHVALUE
FOR UPDATE OF SALESPRICE
END-EXEC.
EXEC SQL OPEN CURSOR2 END-EXEC.
EXEC SQL FETCH CURSOR2
INTO :PARTNAME :PARTNAMEIND,
:SALESPRICE :SALESPRICEIND
END-EXEC.
EXEC SQL UPDATE PURCHDB.PARTS
SET SALESPRICE = :NEWSALESPRICE
WHERE CURRENT OF CURSOR2
END-EXEC.
The "PARTNAME" and "SALESPRICE" are the table columns of the "PURCHDB" inventory parts database and can be replaced with a different database and set of columns. - 3). Type "Save" on the console and press the "Enter" key to update the CURSOR operator for the "SALESPRICE" column in your COBOL program.
Source...