Plsql updating in cursor

The WHERE CURRENT OF clause in an UPDATE or DELETE statement states that the most recent row fetched from the table should be updated or deleted.

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: ,625.00 Employee: 2 Department: 41 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,522.50 Employee: 3 Department: 31 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,540.00 Employee: 4 Department: 10 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,522.50 Employee: 5 Department: 50 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,705.00 Employee: 6 Department: 41 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,260.00 Employee: 7 Department: 41 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,312.50 Employee: 8 Department: 41 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,155.00 Employee: 9 Department: 41 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,365.00 Employee: 10 Department: 41 New Salary:

A cursor contains information on a select statement and the rows of data accessed by it.

All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.

When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.

CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created.

SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

||

A cursor contains information on a select statement and the rows of data accessed by it.All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications.When ISO syntax is used, if INSENSITIVE is omitted, committed deletes and updates made to the underlying tables (by any user) are reflected in subsequent fetches.CREATE TABLE employee 2 (employee_id NUMBER(7), 3 last_name VARCHAR2(25), 4 first_name VARCHAR2(25), 5 userid VARCHAR2(8), 6 start_date DATE, 7 comments VARCHAR2(255), 8 manager_id NUMBER(7), 9 title VARCHAR2(25), 10 department_id NUMBER(7), 11 salary NUMBER(11, 2), 12 commission_pct NUMBER(4, 2) 13 ); Table created. SQL DECLARE 2 CURSOR emp Cursor IS 3 SELECT employee_id, department_id, NVL(salary,0) salary, ROWID 4 FROM employee; 5 lv_record_num PLS_INTEGER DEFAULT 0; 6 BEGIN 7 FOR emp Record IN emp Cursor LOOP 8 lv_record_num := lv_record_num 1; 9 IF emp Record.department_id = 10 OR 10 emp Record.department_id = 41 THEN 11 IF emp Record.salary 2000 THEN 24 emp Record.salary := emp Record.salary * 1.05; 25 ELSE 26 emp Record.salary := emp Record.salary * 1.10; 27 END IF; 28 END IF; 29 UPDATE employee 30 SET salary = emp Record.salary 31 WHERE rowid = emp Record. PUT_LINE(); 43 ROLLBACK; 44 END; 45 / Employee: 1 Department: 50 New Salary: $2,625.00 Employee: 2 Department: 41 New Salary: $1,522.50 Employee: 3 Department: 31 New Salary: $1,540.00 Employee: 4 Department: 10 New Salary: $1,522.50 Employee: 5 Department: 50 New Salary: $1,705.00 Employee: 6 Department: 41 New Salary: $1,260.00 Employee: 7 Department: 41 New Salary: $1,312.50 Employee: 8 Department: 41 New Salary: $1,155.00 Employee: 9 Department: 41 New Salary: $1,365.00 Employee: 10 Department: 41 New Salary: $1,372.35 Update Process Complete.

,372.35 Update Process Complete.

Search for plsql updating in cursor:

plsql updating in cursor-35plsql updating in cursor-47plsql updating in cursor-64

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “plsql updating in cursor”