V_id employees. Employee_id % type;
V_sal employees. Salary is % type;
Cursor cur is the select employee_id, salary from employees;
The begin
The open cur;
Loop
The fetch cur into v_id, v_sal;
If v_sal & lt; Then 3000
Update employees set salary=salary + 100 where employee_id=v_id;
Dbms_output. Put_line (v_id | | 'wages by' | | (v_sal - 100) | | 'to' | | v_sal);
end if;
The fetch cur into v_id, v_sal; - this should write here?
End loop;
Dbms_output. Put_line (cur % rowcount);
The close cur;
end;
CodePudding user response:
LoopThe fetch cur into v_id, v_sal;
Exit the when cur % NOTFOUND;
If v_sal & lt; Then 3000
Update employees set salary=salary + 100 where employee_id=v_id;
Dbms_output. Put_line (v_id | | 'wages by' | | (v_sal - 100) | | 'to' | | v_sal);
end if;
- the fetch cur into v_id, v_sal; - this should write here?
End loop;
CodePudding user response:
Lack of cursor exit conditionWith reference to the following look at https://blog.csdn.net/Alen_Liu_SZ/article/details/80527593
CodePudding user response:
Lack of exit loop conditions, specific can refer to the advice of the 1/f,