Default sort order for cursors in COBOL reading from DB2?
Posted: Wed Apr 18, 2018 2:56 pm
In a db2-Cobol program with restart logic, I have defined a Cursor to select & Update rows as below -
SELECT COL_L, COL_M, COL_N, COL_O
FROM TABLE_1
WHERE COL_A = VALUE_1
AND COL_B = VALUE_2
FOR UPDATE OF
COL_X,
COL_Y
Depending on the values of COL_L, COL_M, COL_N, COL_O, I’ll update certain values to COL_X and COL_Y
Question:
1. Since I didn’t use ORDER BY clause, will the program fetches the data in the same order in the two different runs (- given that there are no inserts or deletes between two runs)?
2. How does row positioned cursor works – On what basis 1st row is selected from the resultant table?
SELECT COL_L, COL_M, COL_N, COL_O
FROM TABLE_1
WHERE COL_A = VALUE_1
AND COL_B = VALUE_2
FOR UPDATE OF
COL_X,
COL_Y
UPDATE CURSOR_NAME
SET COL_X = : VALUE_3
, COL_Y = : VALUE_4
WHERE CURRENT OF CURSOR_NAME
SET COL_X = : VALUE_3
, COL_Y = : VALUE_4
WHERE CURRENT OF CURSOR_NAME
Depending on the values of COL_L, COL_M, COL_N, COL_O, I’ll update certain values to COL_X and COL_Y
Note: ONLY COL_A & COL_B in WHERE clause are part of INDEX of TABLE_1
Question:
1. Since I didn’t use ORDER BY clause, will the program fetches the data in the same order in the two different runs (- given that there are no inserts or deletes between two runs)?
2. How does row positioned cursor works – On what basis 1st row is selected from the resultant table?