Reputation: 1434
When I try to compile this package, I get the error: PLS-00103: Encountered the symbol “BEGIN” when expecting one of the following: end function pragma procedure subtype type current cursor delete exists prior
Can anyone help me, please?
CREATE OR REPLACE PACKAGE PCK_TB_ESTADO
IS
PROCEDURE PRC_INSERE
(P_NM_REDE_FUNCIONARIO IN TB_FUNCIONARIO.NM_REDE_FUNCIONARIO%TYPE,
P_DS_ESTADO IN TB_ESTADO.DS_ESTADO%TYPE,
P_ID_UF IN TB_ESTADO.ID_UF%TYPE,
P_MENS OUT VARCHAR2)
BEGIN
CREATE SEQUENCE SEQ_ESTADO
MINVALUE 1
MAXVALUE 99
START WITH 1
INCREMENT BY 1;
INSERT INTO TB_ESTADO
VALUES (SEQ_ESTADO.NEXTVAL,P_DS_ESTADO,P_ID_UF,SYSDATE,P_NM_REDE_FUNCIONARIO);
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
ROLLBACK;
P_MENS := 'Você tentou executar um comando INSERT ou UPDATE que criou um valor duplicado em um campo restrito por um index único.';
WHEN OTHERS THEN
ROLLBACK;
P_MENS := 'Erro.';
END;
END PCK_TB_ESTADO;
Upvotes: 0
Views: 1369
Reputation: 3094
Here are the Issues:
A Package Specification only contains the signature of the procedures/functions it is supposed to contain. The code for the procs/functions goes into the Package Body
You cannot have a DDL statement directly inside your Procedure. You can however execute DDLs using EXECUTE IMMEDIATE
The Procedure definition in the Package Body should have IS/AS
keyword before BEGIN
Upvotes: 4