SET SERVEROUTPUT ON

DECLARE
  CURSOR kevesfiz IS
    SELECT * FROM EMP WHERE SAL <= 2000
  FOR UPDATE OF COMM NOWAIT;
  egy_dolg EMP%ROWTYPE;
BEGIN
  OPEN kevesfiz;
  LOOP
    FETCH kevesfiz INTO egy_dolg;
    EXIT WHEN kevesfiz%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE('Jutalmat kap: ' || egy_dolg.ENAME);
    UPDATE EMP SET COMM = NVL(COMM, 0) + (SAL * 0.1) WHERE CURRENT OF kevesfiz;
  END LOOP;
  CLOSE kevesfiz;
  DBMS_OUTPUT.PUT_LINE('Program vege.');
END;