Reputation: 13
i'm new in pl sql and this is the first package i'm creating for a school project. I'm using oracle apex, the browser version to compile this code and i get the error mentioned above, Unfortunately i don't know how to debug this. I tried running each procedure and function on it's own to see if they work and i always got "PLS-00103: encountered the symbol "end-of-file."
CREATE OR REPLACE PACKAGE package_farmacie AS
procedure stergere_angajat(nr_angajat angajati_f.ID%type);
procedure stergere;
function salariu_mediu return number;
procedure afisare;
numar_angajati_stersi integer;
sal_mediu number;
end;
CREATE OR REPLACE PACKAGE BODY package_farmacie AS
procedure produse;
procedure salariu_angajat;
procedure salariu_angajat is
cursor c1 is select * from angajati_f where salariu <(select avg(salariu) from angajati_f) order by salariu;
cursor c2 is select * from angajati_f where salariu >(select avg(salariu) from anagajati_f) order by salariu;
begin
dbms_output.put_line(‘Angajati cu salariu mai mic decat media’);
for i in c1 loop
dbms_output.put_line(i.ID||’ ‘||i.prenume||i.salariu);
exit when c1%notfound;
end loop;
dbms_output.put_line(‘Angajati cu salariu peste medie’);
for i in c2 loop
dbms_output.put_line(i.ID||’ ‘||i.prenume||i.salariu);
end loop;
end;
procedure stergere is
numar_angajati_stersi angajati_f.ID%type;
begin
select count(ID)
into numar_angajati_stersi
from sefi_schimb;
delete from sefi_schimb;
dbms_output.put_line('Au fost stersi '|| numar_angajati_stersi ||' angajati!');
end;
function salariu_mediu return number is
sal_mediu angajati_f.salariu%type;
begin
select avg(salariu)
into sal_mediu
from angajati_f;
dbms_output.put_line('Salariul mediu este: '||sal_mediu);
return sal_mediu;
salariu_angajat();
end;
function afisare_angajati return nume is
cursor afisare is SELECT nume FROM angajati_f;
nume_angajat angajati_f.nume%type;
begin
open afisare;
loop
fetch afisare into nume_angajat;
if afisare%NOTFOUND then
exit;
end if;
Dbms_output.put_line(‘Angajati gasiti:’||nume_angajat);
end loop;
close afisare;
end;
procedure stergere_angajat(nr_angajat angajati_f.ID%type) is
id_angajat angajati_f.ID%type;
begin
select ID
into id_angajat
from angajati_f
where ID = nr_angajat;
delete from angajati_f
where ID = nr_angajat;
dbms_output.put_line('Stergere cu succes!');
dbms_output.put_line('A(u)fost sters( e) '|| SQL%ROWCOUNT ||' rand(uri)!');
exception
when no_data_found then
dbms_output.put_line('Id-ul angajatului nu exista!');
angajati := afisare_angajati();
dbms_output.put_line(angajati);
end;
procedure produse is
cursor c_produse (cod_produse_in IN varchar2)
is
select denumire
from produse_f
where cod = cod_produse_in;
prod_denumire produse_f.denumire%type;
begin
dbms_output.put_line('Lista produselor in functie de cod: '||cod_produse_in);
open c_produse(cod_produse_in);
loop
fetch c_produse
into prod_denumire;
if (c_produse%notfound = true) then
close c_produse;
return;
end if;
dbms_output.put_line(prod_denumire);
end loop;
end;
procedure afisare is
begin
produse();
end;
end;
i've checked for typos in my table & columns names and they are correctly written is it the syntax or the whole code is a mess?
Upvotes: 0
Views: 1440
Reputation: 167774
When I copy/paste from your question, you are using the quotes ‘’
when you should be using single straight quotes '
. Make sure that whatever user interface you are using to create your package is not replacing single straight quotes '
with angled quotes.
Also:
function afisare_angajati return nume
Should return a data type rather than a column identifier; such as:
function afisare_angajati return angajati_f.nume%TYPE
angajati := afisare_angajati();
The angajati
variable is not declared; you could just combine the that line with the next to not use an intermediate variable:
dbms_output.put_line(afisare_angajati());
Also cod_produse_in
is not declared outside the cursor, even though you try to use it as a PL/SQL variable outside the cursor.
(Note: I have only looked for syntax errors and have not tried to understand what the code does.)
Upvotes: 1