I have written a procedure to insert data from one table into another table. There is a huge amount of data - a total of 106 millions rows. So I want to put a commit interval on the query.
I have found this script that normally will work and will not take time to get the job done but I don't know why I get an error on
INSERT INTO dlc_pr_activity_remise
VALUES (add all values using ga_array(i).<value in select>)
Errors:
Error(51,1): PL/SQL: SQL Statement ignored
Error(51,47): PL/SQL: ORA-00917: missing comma
My procedure :
create or replace
PROCEDURE ACTIVITY1 AS
BEGIN
DECLARE
commit_interval pls_integer := 250000 ;
uncommitted pls_integer := 0;
fetch_size pls_integer := 2500 ;
cursor g1 is SELECT prr.EVT_DECLENCHEUR ,
prr.BQ_CDF ,
prr.BQ_DOM ,
prr.NUM_COMMERCANT ,
prr.TYPE_CONTRAT_COM ,
prr.COMMERCANT_SIRET ,
prr.TYPE_PRE_COMP ,
prr.BQ_CDF_ID_EBF ,
prr.BQ_DOM_ID_EBF ,
prr.DAT_TRAITEMENT ,
prr.EVT_TYPE_OPERATION ,
prr.DEV_MT_CRE ,
prr.NBR_DECI_MT_CRE ,
prr.REF_FICHIER_TRAITE ,
prr.NUM_CTC ,
prr.REF_FICHIER_ORIGINE ,
prr.ORIGINE_FLUX ,
prr.NUM_EST_REMISE ,
prr.NUM_REMISE_ORIGINE ,
prr.NUM_MACHINE ,
prr.REF_ARCHIVAGE_REM ,
prr.DAT_REMISE ,
prr.SUPPORT_REMISE ,
prr.DAT_REMISE_CALCULEE ,
prr.DAT_VALEUR_REMISE ,
prr.COD_APPLI ,
to_date(SYSDATE,'DD/MM/YYYY')
FROM dlc_pr_remise prr
WHERE NOT EXISTS
(SELECT *
FROM DLC_PR_ACTIVITY_REMISE prao
WHERE prao.num_est_remise = prr.num_est_remise
);
TYPE GL_T is table of gl%rowtype ;
gl_array GL_T;
begin
open gl ;
loop
fetch gl
bulk collect
into gl_array
limit fetch_size ;
forall i in 1 .. gl_arary.count
INSERT INTO dlc_pr_activity_remise values(add all values using ga_array(i).<value in select>)
uncommitted :+ uncommitted + sql%rowcount ;
exit when gl_arary.count < fetch_size ;
if uncommitted >= commit_interval
then
commit ;
uncommitted := 0;
end if ;
end loop ;
commit ;
close gl;
END ;
END ACTIVITY1;