Rowset Positioning top examples to INSERT, UPDATE, DELETE

5 different best examples of Rowset positioning usage in DB2. These examples include to DELETE, UPDATE and SELECT multiple rows.

INSERT, UPDATE and DELETE DB2 Rowset Positioning

Example SQL queries to use rowset positioning to carry INSERT, UPDATE and DELETE of Multi rows

SELECT – FETCH FIRST 20 ROWS WITH ROWSET POSITIONING

FETCH NEXT ROWSET 
FROM C1 FOR 20 ROWS INTO :HVA-EMPNO, :HVA-LASTNAME, :HVA-SALARY :INDA-SALARY
END-EXEC.

UPDATE – ROWS FROM ROWSET POSITIONING

The below query update salary to 5000 in all the rows of rowset result table.

EXEC SQL  
UPDATE DSN8B10.EMP SET SALARY = 50000
WHERE CURRENT OF C1 END-EXEC.

DELETE – ROWS FROM ROWSET POSITIONING

Below query deletes all the rows of rowset positioning result table.

EXEC SQL   
DELETE FROM DSN8B10.EMP
WHERE CURRENT OF C1
END-EXEC.

Recent Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.