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

About the Author : Anurag Pandey | Database cloud Architect | Oracle | SQL Server | PostgreSQL | AI and Data Platform Enthusiast

Anurag Pandey is a Database Architect with expertise in Oracle, PostgreSQL, SQL Server, Linux, and enterprise database platforms and specializes in database architecture, performance tuning, high availability, disaster recovery, cloud modernization, and operational excellence. With extensive experience in enterprise-scale environments, Anurag is passionate about leveraging AI, automation, and modern data platforms to improve reliability, scalability, and business outcomes. He actively contributes to technical communities through knowledge sharing, architecture guidance, and thought leadership in database and data engineering domains.

Follow more articles at

Visit Blog

Oracle Database Deep Health Check Checklist

Oracle Database Deep Health Check Checklist Recommended assessment levels Level Purpose Typical scope L1 Operational health Availability, sp...