rana rana - 1 month ago 6
SQL Question

Error while inserting data into a table using package body

I am getting following error:


'ORA-06550: line 1, column 48:PLS-00103: Encountered the symbol "," when expecting one of the following: := . ( @ % ;'


while trying to run below code:

create or replace PACKAGE BODY "PACKAGE_NAME" As

Procedure MAIN Is

BEGIN

LOAD_DATA;

END MAIN;

Procedure LOAD_DATA Is

V_LC_NARRATIVE VARCHAR2(50) :=
'CDB_LETTER_OF_CREDIT_NARRATIVE.LOAD_DATA';
V_LC_STMT_ENTRY_NO VARCHAR2(50) := 'CDB_LC_STMT_ENTRY_NO.LOAD_DATA';
V_LC_HSCODE VARCHAR2(50) := 'CDB_LETTER_OF_CREDIT_HSCODE.LOAD_DATA';

BEGIN
insert into table_name
(
column1,
column2,...
)
SELECT
column1,
column2,...
FROM Table_2 WHERE ID IS NOT NULL;
COMMIT;

EXECUTE IMMEDIATE ' BEGIN ' || V_LC_NARRATIVE || ', END,';
EXECUTE IMMEDIATE ' BEGIN ' || V_LC_STMT_ENTRY_NO || ', END,';
EXECUTE IMMEDIATE ' BEGIN ' || V_LC_HSCODE || ', END,';

Exception
WHEN OTHERS THEN
ERROR_LOGGER ('PACKAGE_NAME', 'TABLE_NAME','', SQLCODE, substr(SQLERRM, 1, 500));

END LOAD_DATA;

END PACKAGE_NAME;

Answer

Change these lines:

 execute immediate ' BEGIN ' || v_lc_narrative || ', END,';

to

 execute immediate ' BEGIN ' || v_lc_narrative || '; END;';
Comments