How to solve error in creating dynamic SQL? - oracle

I`m trying to insert the result of one dynamic SQL to another table, the result is not 1 column but 2 columns each time with a different number of rows but faced with an error in compile part, in EXECUTE part I try to insert all result from dynamic SQL to the table that I need plus the time and more information of it
CREATE OR REPLACE PROCEDURE P_C_SM_Failure_error_Code_P2P
AS
v_month VARCHAR2(16); -- to get Month for each table
v_day VARCHAR2(16); -- to get day for each table
v_ERRCODE t_c_rpt_resultmsg.code%TYPE;
v_ERRMSG t_c_rpt_resultmsg.MESSAGE%TYPE;
v_param VARCHAR2(16);
v_sql VARCHAR2(3000);
v_result number;
BEGIN
v_sql :='0';
v_param := 'Gateway_G';
v_result := '0';
select to_char(sysdate - 1,'MM') into v_month from dual;
select to_char(sysdate - 1,'DD') into v_day from dual;
-- Get count of P2P
v_sql := '(select count(error_code) as ErrorNo, err_code
from (select error_code from
sm_histable'||v_month||''||v_day||'#ORASMSC01 where orgaccount =
'''||v_param||''' and destaccount = '''||v_param||''' and sm_status <> 1
union all
select error_code from sm_histable'||v_month||''||v_day||'#ORASMSC02
where orgaccount = '''||v_param||''' and destaccount = '''||v_param||'''
and sm_status <> 1 union all
select error_code from sm_histable'||v_month||''||v_day||'#ORASMSC16
where orgaccount = '''||v_param||''' and destaccount = '''||v_param||'''
and sm_status <> 1)
group by err_code)';
EXECUTE IMMEDIATE v_sql INSERT INTO t_c_rpt_result2 values
(trunc(sysdate, 'DD'), err_count, err_code,'Failure_error_Code_P2P');
COMMIT;
--insert into t_c_rpt_result2 values ( trunc(sysdate, 'DD'), v_result,
'Failure_error_Code_P2P' );
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
V_ERRCODE := SQLCODE;
V_ERRMSG := SQLERRM;
INSERT INTO t_c_rpt_resultmsg
(LOGTIME, OBJECTNAME, CODE, MESSAGE, LOGCOMMENT)
VALUES
(SYSDATE,
'P_C_SM_Failure_error_Code_P2P',
v_ERRCODE,
v_ERRMSG,
'select count(error_code) as "ErrorNo", error_code');
COMMIT;
END P_C_SM_Failure_error_Code_P2P;

As mentioned in my comment, there are errors in your code. One immediate i highlighted in my comment. However i could see that you are not fetching the result of the your dynamic query anywhere. See below changes and read my cooments inline:
Assumptions:
1) Dynamic query will return only one row.
CREATE OR REPLACE PROCEDURE P_C_SM_Failure_error_Code_P2P AS
v_month VARCHAR2(16); -- to get Month for each table
v_day VARCHAR2(16); -- to get day for each table
v_ERRCODE t_c_rpt_resultmsg.code%TYPE;
v_ERRMSG t_c_rpt_resultmsg.MESSAGE%TYPE;
v_param VARCHAR2(16);
v_sql VARCHAR2(3000);
v_result number;
v_err_count numberl;
BEGIN
v_sql := '0';
v_param := 'Gateway_G';
v_result := '0';
select to_char(sysdate - 1, 'MM') into v_month from dual;
select to_char(sysdate - 1, 'DD') into v_day from dual;
-- Get count of P2P
v_sql := '(select count(error_code) as ErrorNo, err_code
from (select error_code from
sm_histable' || v_month || '' || v_day || '#ORASMSC01 where orgaccount =
''' || v_param || ''' and destaccount = ''' || v_param ||
''' and sm_status <> 1
union all
select error_code from sm_histable' || v_month || '' || v_day ||
'#ORASMSC02
where orgaccount = ''' || v_param || ''' and destaccount = ''' ||
v_param || '''
and sm_status <> 1 union all
select error_code from sm_histable' || v_month || '' || v_day ||
'#ORASMSC16
where orgaccount = ''' || v_param || ''' and destaccount = ''' ||
v_param || '''
and sm_status <> 1)
group by err_code)';
-- You must hold the result of v_sql to some variable
EXECUTE IMMEDIATE v_sql into v_err_count,v_errcode ;
INSERT INTO t_c_rpt_result2
values
(trunc(sysdate, 'DD'),
v_err_count, -- Inserting the records to the table
v_errcode,
'Failure_error_Code_P2P');
COMMIT;
--insert into t_c_rpt_result2 values ( trunc(sysdate, 'DD'), v_result, 'Failure_error_Code_P2P');
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
V_ERRCODE := SQLCODE;
V_ERRMSG := SQLERRM;
INSERT INTO t_c_rpt_resultmsg
(LOGTIME,
OBJECTNAME,
CODE,
MESSAGE,
LOGCOMMENT)
VALUES
(SYSDATE,
'P_C_SM_Failure_error_Code_P2P',
v_ERRCODE,
v_ERRMSG,
'select count(error_code) as "ErrorNo", error_code');
COMMIT;
END P_C_SM_Failure_error_Code_P2P;
PS: Not tested.

Related

ORA-00928 missing select keyword ora-06512 at dbms_sql at line 1120 load_csv at line 84

dbms_sql is throwing error at dbms.parse().
[form error]
I'm getting this error while trying to upload a CSV file into Oracle 12c database table.it is failing at dbms_sql.parse() function because I'm giving insert query as an argument instead of
load_csv code is attached.
create or replace FUNCTION load_csv ( p_table in varchar2,
p_dir in varchar2 DEFAULT 'THINS_UPD' ,
P_FILENAME in varchar2 ,
p_ignore_headerlines IN INTEGER DEFAULT 1,
p_delimiter in varchar2 default ',',
p_optional_enclosed in varchar2 default '"' )
return number
is
/***************************************************************************
-- PROCEDURE LOAD_CSV
-- PURPOSE: This Procedure read the data from a CSV file.
-- And load it into the target oracle table.
-- Finally it renames the source file with date.
--
-- P_FILENAME
-- The name of the flat file(a text file)
--
-- P_DIRECTORY
-- Name of the directory where the file is been placed.
-- Note: The grant has to be given for the user to the directory
-- before executing the function
--
-- P_IGNORE_HEADERLINES:
-- Pass the value as '1' to ignore importing headers.
--
-- P_DELIMITER
-- By default the delimiter is used as ','
-- As we are using CSV file to load the data into oracle
--
-- P_OPTIONAL_ENCLOSED
-- By default the optionally enclosed is used as '"'
-- As we are using CSV file to load the data into oracle
--
**************************************************************************/
l_input utl_file.file_type;
l_lastLine varchar2(4000);
l_cnames varchar2(4000);
l_bindvars varchar2(4000);
l_status integer;
l_cnt number default 0;
l_rowCount number default 0;
l_sep char(1) default NULL;
L_ERRMSG varchar2(4000);
V_EOF BOOLEAN := false;
l_theCursor number default dbms_sql.open_cursor;
v_insert varchar2(1100);
begin
l_cnt := 1;
for TAB_COLUMNS in (
select column_name,data_type from user_tab_columns where table_name=p_table order by column_id
) loop
l_cnames := l_cnames || tab_columns.column_name || ',';
--Dbms_Output.put_line(tab_columns.column_name ||'colname');
-- l_bindvars := l_bindvars || case when tab_columns.data_type in ('DATE', 'TIMESTAMP(6)') then 'to_date(:b' || l_cnt || ',"YYYY-MM-DD HH24:MI:SS"),' else ':b'|| l_cnt || ',' end;
l_bindvars := l_bindvars || case when tab_columns.data_type in ('DATE', 'TIMESTAMP(6)') then ':b'|| l_cnt || ',' else ':b'|| l_cnt || ',' end;
l_cnt := l_cnt + 1;
end loop;
l_cnames := rtrim(l_cnames,',');
L_BINDVARS := RTRIM(L_BINDVARS,',');
L_INPUT := UTL_FILE.FOPEN( P_DIR, P_FILENAME, 'r' );
IF p_ignore_headerlines > 0
THEN
BEGIN
FOR i IN 1 .. p_ignore_headerlines
LOOP
UTL_FILE.get_line(l_input, l_lastLine);
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_eof := TRUE;
end;
END IF;
v_insert :='insert into ' || p_table || '(' || l_cnames || ') values (' || l_bindvars || ')';
Dbms_Output.put_line(l_theCursor||'cursor'||l_bindvars||'---'||l_cnames);
if not v_eof THEN
Dbms_Output.put_line(l_theCursor||'-'||'insert into ' || p_table || '(' || l_cnames || ') values (' || l_bindvars || ')');--Akash added
--dbms_sql.parse( l_theCursor, 'insert into ' || p_table || '(' || l_cnames || ') values (' || l_bindvars || ');' dbms_sql.native );
DBMS_SQL.parse(l_theCursor ,v_insert, dbms_sql.native );
Dbms_Output.put_line(112);
loop
begin
utl_file.get_line( l_input, l_lastLine );
exception
when NO_DATA_FOUND then
exit;
end;
if length(l_lastLine) > 0 then
for i in 1 .. l_cnt-1
LOOP
dbms_sql.bind_variable( l_theCursor, ':b'||i,
rtrim(rtrim(ltrim(ltrim(
REGEXP_SUBSTR(l_lastline,'(^|,)("[^"]*"|[^",]*)',1,i),p_delimiter),p_optional_enclosed),p_delimiter),p_optional_enclosed));
end loop;
begin
l_status := dbms_sql.execute(l_theCursor);
l_rowCount := l_rowCount + 1;
exception
when OTHERS then
L_ERRMSG := SQLERRM;
insert into BADLOG ( TABLE_NAME, ERRM, data, ERROR_DATE )
values ( P_TABLE,l_errmsg, l_lastLine ,systimestamp );
end;
end if;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_input );
commit;
end if;
insert into IMPORT_HIST (FILENAME,TABLE_NAME,NUM_OF_REC,IMPORT_DATE)
values ( P_FILENAME, P_TABLE,l_rowCount,sysdate );
Dbms_Output.put_line(P_DIR||'-'||P_FILENAME);--added by Akash
RETURN L_ROWCOUNT;
end LOAD_CSV;

Oracle execute immediate

Have oracle stuff that I can't figure out where is the problem, if you could help me out here
ORA-00911: invalid character
ORA-06512: at line 20
Line 20 is EXECUTE IMMEDIATE SQL_STMT INTO P_COUNT USING L_RB_OD, L_RB_DO;
I have like 10-15 tables, and each of them have similar names and column that is TableName_ID which contains sequence, so I made a procedure that will select certain amount of data (P_Bucket) from table (P_Table).
It will also select total amount of rows selected into P_COUNT and return P_DATA sys_refcursor. Procedure compiles successfully but won't execute.
DECLARE
P_PAR_01 VARCHAR2(5) := '2';
P_BUCKET NUMBER := 200;
P_TABLE VARCHAR2(15) := 'KB_FL_1';
P_COUNT NUMBER;
P_DATA SYS_REFCURSOR;
L_RB_OD NUMBER;
L_RB_DO NUMBER;
L_RB NUMBER;
SQL_STMT VARCHAR2(1000);
BEGIN
L_RB := CAST(P_PAR_01 AS NUMBER);
L_RB_DO := L_RB * P_BUCKET;
L_RB_OD := L_RB_DO - (P_BUCKET - 1);
SQL_STMT := 'SELECT COUNT(*)
FROM ' || P_TABLE || '
WHERE 1 = 1
AND ' || P_TABLE || '_ID BETWEEN :1 AND :2'; -- was :2;';
EXECUTE IMMEDIATE SQL_STMT INTO P_COUNT USING L_RB_OD, L_RB_DO;
OPEN P_DATA FOR
'SELECT * FROM ' || P_TABLE || '
WHERE 1 = 1
AND ' || P_TABLE || ' _ID BETWEEN :1 AND :2
ORDER BY ID_LICA' USING L_RB_OD, L_RB_DO; -- was ORDER BY ID_LICA;'
END;
EDIT: As comments says, dynamic SQL don't use semicolons, but even after removal of semicolons I get error invalid character at OPEN P_DATA FOR
You have to remove semicolons from the dynamic SQL; also, you have to remove a space in the second dynamic query: ' _ID' should be '_ID'.
This should work:
DECLARE
P_PAR_01 VARCHAR2(5) := '2';
P_BUCKET NUMBER := 200;
P_TABLE VARCHAR2(15) := 'KB_FL_1';
P_COUNT NUMBER;
P_DATA SYS_REFCURSOR;
L_RB_OD NUMBER;
L_RB_DO NUMBER;
L_RB NUMBER;
SQL_STMT VARCHAR2(1000);
BEGIN
L_RB := CAST(P_PAR_01 AS NUMBER);
L_RB_DO := L_RB * P_BUCKET;
L_RB_OD := L_RB_DO - (P_BUCKET - 1);
SQL_STMT := 'SELECT COUNT(*)
FROM ' || P_TABLE || '
WHERE 1 = 1
AND ' || P_TABLE || '_ID BETWEEN :1 AND :2';
EXECUTE IMMEDIATE SQL_STMT INTO P_COUNT USING L_RB_OD, L_RB_DO;
OPEN P_DATA FOR
'SELECT * FROM ' || P_TABLE || '
WHERE 1 = 1
AND ' || P_TABLE || '_ID BETWEEN :1 AND :2
ORDER BY ID_LICA' USING L_RB_OD, L_RB_DO;
END;

Not able to execute with clause in dynamic sql

I'm trying to execute below statement using dynamic SQL but I'm getting this exception
"ORA-00911:
invalid character on ORA-06512".
When i remove semicolon(;) the query runs but it's taking a long time and is not able to display output.
How do I clear this problem? Is anywhere I'm doing wrong? if so please guide me.
Below is my code:
DECLARE
mapping_rule VARCHAR2 (10000)
:= 'SALES_REVIEW.NET_VALUE-SALES_REVIEW.GROSS_VALUE+SALES_REVIEW_TABLE.PLNT';
v_mapp_rule VARCHAR2 (10000);
v_mapp_rule_1 VARCHAR2 (10000);
v_chk_flag CHAR (1) := 'Y';
v_mapping_rule VARCHAR2 (10000);
v_str VARCHAR2 (30000);
BEGIN
<<dest_stmt>>
DBMS_OUTPUT.put_line (v_chk_flag);
IF v_chk_flag = 'Y'
THEN
v_mapping_rule := mapping_rule;
ELSE
v_mapping_rule := v_mapp_rule_1;
END IF;
v_str :=
'WITH sel_col (rowno, mapp_rule)
AS ( SELECT ROWNUM rowno,
REGEXP_SUBSTR ( ''' || v_mapping_rule
|| ''',''([+--*!#/#$%^&()=<>,?]+|[A-Z0-9_.'''']+|\s+)'',
1,
LEVEL)
mapp_rule
FROM DUAL
CONNECT BY REGEXP_SUBSTR ('''
|| v_mapping_rule
|| ''',''([+--*!#/#$%^&()=<>,?]+|[A-Z0-9_.'''']+|\s+)'',
1,
LEVEL)
IS NOT NULL)
SELECT listagg (
CASE WHEN B.MAPP_RULE IS NOT NULL THEN B.MAPP_RULE
ELSE D.MAPP_RULE END,
'''')
WITHIN GROUP (ORDER BY d.rowno)
FROM RRR_PROCESS_DTLS a
JOIN RRR_PROCESS_MAPPING_DTLS b
ON A.PROCESS_ID = B.PROCESS_ID
AND A.COMPANY_ID = B.COMPANY_ID
JOIN RRR_DEST_TABLE_DTLS C
ON A.DEST_TABLE = C.TABLE_ID
AND A.COMPANY_ID = C.COMPANY_ID
RIGHT JOIN sel_col d
ON CONCAT (CONCAT (C.TABLE_NAME, ''.''), B.DEST_COLUMN) =
d.mapp_rule
AND A.PROCESS_ID = 12
AND A.COMPANY_ID = 2
ORDER BY d.rowno;';
DBMS_OUTPUT.put_line (v_str);
EXECUTE IMMEDIATE v_str into v_mapp_rule_1 ;
DBMS_OUTPUT.put_line ('bf ' || v_mapp_rule_1);
IF v_mapp_rule_1 IS NOT NULL
THEN
v_chk_flag := 'N';
GOTO dest_stmt;
END IF;
DBMS_OUTPUT.put_line (v_mapp_rule_1);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE (
SQLCODE
|| ' -ERROR- '
|| SQLERRM
|| ' on '
|| DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
END;

Creating partitions

Hei, I am having problem with creating partitions using PL/SQL procedure:
ORA-14019: partition bound element must be one of: string, datetime or
interval literal, number, or MAXVALUE
It seems like problem is in format of attribute r.partition_date, I already run some tests script and tried different date format, but nothing helped.
Format of column partition_date : 2017-09-01
I am running this procedure:
declare
v_new_part varchar2(30);
v_prev_part varchar2(30);
v_sql varchar2(4000);
v_table varchar(30) := 'RL2_OUTDW_CORP_PRISK_REV_B';
begin
for r in (select distinct a.partition_date , a.partition_name from XX a
where a.PARTITION_NAME = 'PARTITION_20170831'
order by 1)
loop
v_sql := 'alter table ' || v_table || ' SPLIT PARTITION
PARTITION_30000101
at (''N'',to_date(' || r.partition_date || ',''yyyy.mm.dd''))
into (partition ' || r.partition_name || ' ,partition
PARTITION_30000101)';
execute immediate v_sql;
end loop;
end;
/
Even though this one is working:
declare
v_new_part varchar2(30);
v_prev_part varchar2(30);
v_sql varchar2(4000);
v_table varchar(30) := 'RL2_OUTDW_CORP_PRISK_REV_B';
begin
for r in (select distinct a.partition_date , a.partition_name from XX a
where rownum = '1'
order by 1)
loop
v_sql := 'alter table ' || v_table || ' SPLIT PARTITION
PARTITION_30000101
at ("N",to_date(''2017-01-29'',''yyyy.mm.dd''))
into (partition ' || 'PARTITION_20170129' || ' ,partition
PARTITION_30000101)';
execute immediate v_sql;
end loop;
end;
/
Thank you for advice.
first of all remove asterisks in this
(''N'',to_date(' || **r.partition_date** || ',''yyyy.mm.dd'')) part of first sentence.
And format inthe cursor
for r in (select distinct to_char(a.partition_date,'yyyy.mm.dd')
par_date , a.partition_name from XX a where rownum = '1' order by 1)
And add two quotations around :
(''N'',to_date(' ''|| r.par_date||'' ',''yyyy.mm.dd''))
SQL>set serveroutput on;
SQL> declare
v_new_part varchar2(30);
v_prev_part varchar2(30);
v_sql varchar2(4000);
v_table varchar(30) := 'RL2_OUTDW_CORP_PRISK_REV_B';
begin
for r in (select distinct to_char(a.partition_date,'yyyy.mm.dd') par_date , a.partition_name from XX a
where a.PARTITION_NAME = 'PARTITION_20170831'
order by 1)
loop
v_sql := 'alter table ' || v_table || ' SPLIT PARTITION
PARTITION_30000101
at (''N'',to_date('''|| r.par_date || ''',''yyyy.mm.dd''))
into (partition ' || r.partition_name || ' ,partition
PARTITION_30000101)';
dbms_output.put_line(v_sql);
execute immediate v_sql;
end loop;
end;
/
I don't understand the purpose of "N" but I think it should be this:
v_sql := 'alter table ' || v_table || ' SPLIT PARTITION
PARTITION_30000101
at (DATE '''||TO_CHAR(r.partition_date,'yyyy-mm-dd')||''')
into (partition ' || r.partition_name || ' ,partition
PARTITION_30000101)';
Note, when you use DATE literal then format is fixed YYYY-MM-DD, otherwise use like
at (TO_DATE('''|| TO_CHAR(r.partition_date,'dd.mm.yyyy') ||''', ''dd.mm.yyyy'')`

The cursor for loop that contains DML statements should be refactored to use

If I compiled my procedure I dont get error but I see this text(how Can I use this advice):
A cursor for loop that contains DML statements should be refactored to use BULK COLLECTION and FORALL
If I compiled this I got always score:
start:2013-11-21 08:16:54
end:2013-11-21 08:16:54
My code:
CREATE OR REPLACE PROCEDURE PROC_AAA
IS
PRAGMA AUTONOMOUS_TRANSACTION;
company_ VARCHAR2 (2) := 'IT';
ok_ BOOLEAN;
updated_ BOOLEAN;
error_msg_ VARCHAR2 (4000);
category_ VARCHAR2 (50);
exist_atrribute_id_ VARCHAR2 (50);
exist_value_ NUMBER;
objid_ ROWID;
var_rows NUMBER (5);
CURSOR cur_dane_wej
IS
SELECT *
FROM dane_wejsciowe_cns
WHERE status = 'NEW'
FOR UPDATE;
BEGIN
DBMS_OUTPUT.put_line (
'start:' || TO_CHAR (SYSDATE, 'YYYY-MM-DD hh24:mi:ss'));
FOR cur_dane_wej_read IN cur_dane_wej
LOOP
BEGIN
SAVEPOINT cur_dane_wej_svp;
updated_ := FALSE;
error_msg_ := NULL;
category_ := TERMINAL_API.Get_Category_Id (cur_dane_wej_read.IMEI_NO);
exist_atrribute_id_ :=
IFSAPP.SER_NUM_ATTRIBUTE_API.CHECK_EXIST (
COMPANY_,
category_,
cur_dane_wej_read.IMEI_NO,
cur_dane_wej_read.KOD_CECHY);
SELECT COUNT (*)
INTO exist_value_
FROM IFSAPP.SER_NUM_ATTRIBUTE
WHERE SERIAL_NO = cur_dane_wej_read.IMEI_NO
AND COMPANY = company_
AND CATEGORY_ID = category_
AND ATTRIBUTE_ID = cur_dane_wej_read.WARTOSC_CECHY
AND NVL (VALUE, '_dummy_') =
NVL (cur_dane_wej_read.KOD_CECHY, '_dummy_');
DBMS_OUTPUT.put_line (
cur_dane_wej_read.KOD_CECHY
|| ' '
|| cur_dane_wej_read.WARTOSC_CECHY);
DBMS_OUTPUT.put_line (
'kategoria: '
|| category_
|| ' imei: '
|| cur_dane_wej_read.IMEI_NO);
IF exist_atrribute_id_ = 'TRUE'
THEN
SELECT objid
INTO objid_
FROM SER_NUM_ATTRIBUTE
WHERE COMPANY = company_
AND CATEGORY_ID = category_
AND SERIAL_NO = cur_dane_wej_read.IMEI_NO
AND ATTRIBUTE_ID = cur_dane_wej_read.KOD_CECHY;
DBMS_OUTPUT.put_line ('objid: ' || objid_);
IF exist_value_ > 0
THEN
DBMS_OUTPUT.put_line ('--> wartosc cechy istnieje ');
NULL;
ELSE
DBMS_OUTPUT.put_line ('zmodyfikowano wartosc cechy');
updated_ := TRUE;
END IF;
ELSE
DBMS_OUTPUT.put_line (
'kod cechy nie istnieje.. trwa dodanie nowego kodu cechy');
-- IFSAPP.SER_NUM_ATTRIBUTE_API.SET_VALUE (company_, category_id_,cur_dane_wej_read.IMEI_NO, cur_dane_wej_read.KOD_CECHY, cur_dane_wej_read.WARTOSC_CECHY, 'DODANO NOWY KOD CECHY' );
updated_ := TRUE;
END IF;
IF updated_ = TRUE
THEN
DBMS_OUTPUT.put_line ('aktualizacja danych w tabeli wejsciowej');
UPDATE dane_wejsciowe_cns
SET status = 'DONE',
MESSAGE = ' ',
DATA_PRZETWORZENIA = SYSDATE
WHERE CURRENT OF cur_dane_wej;
ELSE
UPDATE dane_wejsciowe_cns
SET status = 'SKIPPED',
MESSAGE = ' ',
DATA_PRZETWORZENIA = SYSDATE
WHERE CURRENT OF cur_dane_wej;
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
ROLLBACK TO cur_dane_wej_svp;
error_msg_ := 'Błąd: - ' || SQLCODE || ' -ERROR- ' || SQLERRM;
UPDATE dane_wejsciowe_cns
SET status = 'ERROR',
MESSAGE = error_msg_,
DATA_PRZETWORZENIA = SYSDATE
WHERE CURRENT OF cur_dane_wej;
COMMIT;
END;
END LOOP;
COMMIT;
DBMS_OUTPUT.put_line (
'end:' || TO_CHAR (SYSDATE, 'YYYY-MM-DD hh24:mi:ss'));
END PROC_AAA;
Learn to use bulk collections, take a look at this article.

Resources