rcrd18
rcrd18

Reputation: 3

Procedure: PLS - 00103 error

I have a procedure that does a transaction from a table to another. I already did the code, but it gets me this error

Error(89,59): PLS-00103: Encountered the symbol ";" when expecting one of the following: * & = - + < / > at in is mod remainder not rem then <expoente (**)> <> or != or ~= >= <= <> and or like LIKE2_ LIKE4_ LIKEC_ between overlaps || multiset year DAY_ member SUBMULTISET_

I can't figure out what I'm doing wrong!

Here's my code:

    create or replace procedure arm_inst (
    p_cod_armazem_zona in varchar2,
    p_cod_instituicao in varchar2)

is 
    qn_cg_pd number(8);
    qn_cm_pd number(8);
    qn_cp_pd number(8);
    qn_cg_ar number(8);
    qn_cm_ar number(8);
    qn_cp_ar number(8);
    estado_pd char (8);
begin
    select estado_ped
    into estado_pd
    from pedidos 
    where cod_instituicao = p_cod_instituicao;

    select quantidade_az_cg, quantidade_az_cm, quantidade_az_cp
    into qn_cg_ar, qn_cm_ar, qn_cp_ar
    from armazem_zona
    where armazem_zona = p_cod_armazem_zona;    

if (estado_pd = 'Pendente') then
  select quantidade_pedida_cg, quantidade_pedida_cm, quantidade_pedida_cp
  into qn_cg_pd, qn_cm, qn_cp
    from pedidos
    where cod_instituicao = p_cod_instituicao;

        if(qn_cg_pd <= qn_cg_ar) then -- verifica quantidade cabazes grandes
            update pedidos
            set estado_ped = 'Aprovado' --se e verdadeira da aprovado
            where cod_instituicao = p_cod_instituicao;

            update armazem_zona -- faz update da tabela armazem com as 
            set qn_cg_ar = qn_cg_ar - qn_cg_pd -- quantidades
            where cod_armazem_zona = p_cod_armazem_zona;
      commit;
        else if(qn_cg_pd > qn_cg_ar)then -- se nao for verdadeira da recusado
            update pedidos
            set estado_pd = 'Recusado'
            where cod_instituicao = p_cod_instituicao;
    end if;
        end if;
        if(qn_cm_pd <= qn_cm_ar)then --verifica quantidade cabazes medias
            update pedidos 
            set estado_pd = 'Aprovado'
            where cod_instituicao = p_cod_instituicao;

            update armazem_zona
            set qn_cm_ar = qn_cm_ar - qn_cm_pd
            where cod_armazem_zona = p_cod_armazem_zona;

        else if(qn_cm_pd > qn_cm_ar)then-- condicao é falsa
            update pedidos
            set estado_pd = 'Recusado'
            where cod_instituicao = p_cod_instituicao;
    end if;
        end if;
        if(qn_cp_pd <= qn_cp_ar) then
            update pedidos
            set estado_pd = 'Aprovado'
            where cod_instituicao = p_cod_instituicao;

            update armazem_zona 
            set qn_cp_ar = qn_cp_ar - qn_cp_pd
            where cod_armazem_zona = p_cod_armazem_zona;
        else if(qn_cp_pd > qn_cp_ar) then 
            update pedidos
            set estado_pd = 'Recusado'
            where cod_instituicao = p_cod_instituicao;
        end if;
    end if;

        select estado_pd 
        from pedidos
        where cod_instituicao = p_cod_instituicao;
        if (estado_pd = 'Aprovado') then
            update pedidos
            set estado_pd = 'Aprovado'
            where cod_instituicao = p_cod_instituicao;
        else if (estado_pf != 'Aprovado') then
            update pedidos
            set estado_pd = 'Reprovado'
            where cod_instituicao = p_cod_instituicao;
    end if;
    end if;

        elsif (dbms_output.put_line('O pedido já foi avaliado'));
        end if;
commit;
end;

Any help would be appreciated! :)

Upvotes: 0

Views: 92

Answers (2)

Alex Poole
Alex Poole

Reputation: 191235

Line 89 seems to be this:

elsif (dbms_output.put_line('O pedido já foi avaliado'));

elsif requires a test; not sure if you're meant to be checking for something else there to decide whether to display that message, or if you just wanted an else:

else
  dbms_output.put_line('O pedido já foi avaliado');
end if;

This might be a little easier to follow with more consistent indentation...

That's the cause of the specific PLS-00103 you're asking about, but it's just the first error it reports in this case - seems like it gives up because of structural errors, before digging further into the statement syntax. As CorradoPiola noted, you're at least missing an into in the select at line 75, and there might be others that are gradually uncovered as the compiler gets further after each correction.

Upvotes: 0

Corrado Piola
Corrado Piola

Reputation: 869

Near the end of your code:

select estado_pd 
from pedidos
where cod_instituicao = p_cod_instituicao;

if (estado_pd = 'Aprovado') then

It's missing an

INTO estado_pd

in your select statement.

Upvotes: 1

Related Questions