Wednesday, September 20, 2023

How to copy data from one table to another table using PL/SQL procedure - cursor commit interval ?

 

Copy data from one table to another table using PL/SQL procedure - cursor 


DECLARE

 i NUMBER := 0; 

 

 CURSOR G1 IS SELECT * FROM AWAIS; 

 

 BEGIN 

  FOR c1 in G1 LOOP 

    INSERT INTO AWAIS_STG (EMPLOYEE_ID, FIRST_NAME, LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) VALUES (c1.EMPLOYEE_ID, c1.FIRST_NAME, c1.LAST_NAME,c1.EMAIL,c1.PHONE_NUMBER,c1.HIRE_DATE,c1.JOB_ID,c1.SALARY,c1.COMMISSION_PCT,c1.MANAGER_ID,c1.DEPARTMENT_ID) ; 

i:=i+1; 

if i> 4096

THEN 

  COMMIT; 

  DBMS_OUTPUT.PUT_LINE('Total rows: '|| 'COMMIT');

i:=0; 

    END IF; 

END LOOP;   

END;

No comments:

Post a Comment