How to run PROCEDURE and FUNCTION at the same time?

0

I have this plsql code and I must run at the same time:

/*Testar se o codigo é valido*/
CREATE OR REPLACE FUNCTION TESTE1(cod number)
RETURN BOOLEAN IS
begin
  if(cod>0)then
    return true; 
  end if;

 return false;  

end;


/*varrer o banco de acordo com o codigo*/
CREATE OR REPLACE PROCEDURE BUSCA1(cod number) is
 nomeT VARCHAR2(20);
begin

/* testa1*/
if(TESTE1(cod)=true)then
  select * 
   into nomeT
  from turma
   where CD_TURMA = cod;

   dbms_output.put_line(nomeT);
else
     dbms_output.put_line('Codigo invalido');
end if;

EXCEPTION
    WHEN OTHERS THEN
        dbms_output.put_line('Não foi possível verificar');
end

TEST THE CODE

EXECUTE SEARCH1 (3);

Erro a partir da linha : 38 no comando -
EXECUTE BUSCA1(3)
Relatório de erros -
ORA-06550: line 1, column 7:
PLS-00905: object DBAMV.BUSCA1 is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
    
asked by anonymous 23.01.2018 / 17:08

1 answer

0

I'll use the anonymous code to answer my question:

DECLARE

    /*Testar se o codigo é valido*/
    FUNCTION TESTE(cod number)
    RETURN BOOLEAN IS
    begin
      if(cod>0)then
        return true; 
      end if;      
    return false;  
    end;/*FUNCTION*/

    /*varrer o banco de acordo com o codigo*/   

    PROCEDURE BUSCA(cod number) is
     nomeT VARCHAR2(20);
    begin

    /* testa*/
    if(TESTE(cod)=true)then
      select ds_turma 
       into nomeT
      from turma
       where CD_TURMA = cod;

       dbms_output.put_line(nomeT);
    else
         dbms_output.put_line('Codigo invalido');
    end if;

    EXCEPTION
        WHEN OTHERS THEN
            dbms_output.put_line('Não foi possível verificar');
    end;/*PROCE*/
 BEGIN
    -- Inicio do programa
    BUSCA(3);
 END; /
    
23.01.2018 / 17:39