0

I just referred to similar post related to same ORA & PLS error I faced, but still I can't resolve it using provided solution.

I get the following error: PLS-00103: Encountered the symbol “end-of-file” when expecting one of the following: begin function pragma procedure

My code:

create package PACHET is 
    procedure adaugaAngajat (v_id angajati.id_ang%type, v_idL angajati.id_lab%type, v_numeP angajati.nume%type, v_prenume angajati.prenume%type, v_ore angajati.ore_lucrate%type, v_sal angajati.salariul%type, v_dat angajati.data_angajare%type, v_tel angajati.telefon%type, v_post angajati.postocupat%type );
    procedure modificaAngajat(v_id angajati.id_ang%type, v_idL angajati.id_lab%type, v_numeP angajati.nume%type, v_prenume angajati.prenume%type, v_ore angajati.ore_lucrate%type, v_sal angajati.salariul%type, v_dat angajati.data_angajare%type, v_tel angajati.telefon%type, v_post angajati.postocupat%type );
    function verifica_telefon(v_tel angajati.telefon%type)
    return boolean;
    exp1 exception;
end;
    
create or replace package body PACHET is
    procedure adaugaAngajat (v_id angajati.id_ang%type, v_idL angajati.id_lab%type, v_numeP angajati.nume%type, v_prenume angajati.prenume%type, v_ore angajati.ore_lucrate%type, v_sal angajati.salariul%type, v_dat angajati.data_angajare%type, v_tel angajati.telefon%type, v_post angajati.postocupat%type)
    is 
    begin
        if ( verifica_telefon(v_tel)) 
        then 
            raise exp1;
        else
            insert into angajati values (v_id, v_idL, v_numeP, v_prenume, v_ore, v_sal, v_dat, v_tel, v_post);
        end if;
    exception 
        when exp1 then
            dbms_output.put_line('Exista deja acest angajat!');
    end;
William Robertson
  • 15,273
  • 4
  • 38
  • 44
  • 2
    the existing code is missing. First of all, add a slash after the first semi-colon which ends ths specification of the package. Seems no problem provided you add the body of `modificaAngajat` and `verifica_telefon` to the package body and adding an `end;` following them. – Barbaros Özhan May 23 '21 at 11:03
  • Formatting your code makes it easier to spot mismatched begin/end keywords etc. – William Robertson Jun 02 '21 at 22:45

2 Answers2

0

As you tagged the question with Oracle Apex, I presume you're trying to create that package in its SQL Workshop. Of so, it can't execute more than a single statement at a time.

Therefore, put only package specification into the editor and run it. Then delete it and put package body into the editor and run that piece of code.

Alternatively, select (paint it blue) package spec statement and run it; then deselect it and select package body instead to run that statement.

Littlefoot
  • 131,892
  • 15
  • 35
  • 57
0

PLS-00103, In short, this error means you have done some syntax error in your pl/SQL code, adding syntax that we should follow

--Firstly creating a declaration of a package

CREATE OR REPLACE PACKAGE PACHET 
IS
PROCEDURE EXAMPLE(...);
.
.
END PACHET;
/

I think you have not ended the package and that is causing an error if I am not wrong or you have not pasted your full code, also you can add the name of the procedure or package with the end statements that would make it easy to follow the code. Also first define the package(specs) and then run the body part.

create or replace package body PACHET is
procedure adaugaAngajat (v_id angajati.id_ang%type, v_idL angajati.id_lab%type, v_numeP angajati.nume%type, v_prenume angajati.prenume%type, v_ore angajati.ore_lucrate%type, v_sal angajati.salariul%type, v_dat angajati.data_angajare%type, v_tel angajati.telefon%type, v_post angajati.postocupat%type)
is 
begin
if ( verifica_telefon(v_tel)) 
then 
raise exp1;
else  insert into angajati values (v_id, v_idL, v_numeP, v_prenume, v_ore, v_sal, v_dat, v_tel, v_post);
end if;
exception 
when exp1 then
dbms_output.put_line('Exista deja acest angajat!');
end adaugaAngajat;
end PACHET;
/
Ashish Mishra
  • 704
  • 1
  • 6
  • 20