Search code examples
stored-proceduresplsqlplsqldeveloper

Stored procedure is not getting complied


I am trying to run the below stored procedure in Oracle pl/sql. I am trying to fetch data from join in cursor using table 1 and table 2 and update the output in Table 3, however its giving me compliation error near declare. The queries are working fine.

create or replace PACKAGE BODY PKG_LOAD_BY_ROWID AS
PROCEDURE PRC_LOAD_BY_ROWID AS
DECLARE
N1 NUMBER;
VAR_ROWID_OBJECT VARCHAR2(255);
VAR_PRTY_FK VARCHAR2(255);
V_OUT_ERROR_MSG VARCHAR2(1000);
v_out_return_code number;

CURSOR C1 IS
SELECT PX.ROWID_OBJECT , A.PRTY_FK 
FROM TABLE_1 PX
INNER JOIN
TABLE_2 A
ON
substr(PX.PKEY_SRC_OBJECT,8,INSTR(PX.PKEY_SRC_OBJECT,'|')+8)=A.ALT_ID_VAL
WHERE A.ALT_ID_TYP='DUMMY1' AND PX.ROWID_SYSTEM='SRC';
BEGIN
SELECT COUNT(1) INTO N1  FROM TABLE_3 WHERE SRC_SYSTEM='SRC2' AND ROWID_OBJECT IS NULL;
BEGIN
OPEN C1;
FOR i in 1..n1
LOOP
FETCH C1 INTO VAR_ROWID_OBJECT, VAR_PRTY_FK;
UPDATE TABLE3 SET ROWID_OBJECT= VAR_ROWID_OBJECT WHERE
SRC_KEY=VAR_PRTY_FK;
COMMIT;
END LOOP;
CLOSE C1;
v_out_return_code :=0;
DBMS_OUTPUT.put_line('Rowid_object updated successfully for VVA');
EXCEPTION
when others then
 out_error_msg := 'Updation Error';
 DBMS_OUTPUT.put_line (out_error_msg);
END;
END;
END PKG_LOAD_BY_ROWID;

However, I am getting compilation error:

Error(2,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following:     begin function pragma procedure subtype type current cursor delete    exists prior external language

Oracle Version:


Solution

  • You don't need Declare keyword for the procedure, it is only for anonymous block. Just remove declare and try it.