Error executing function in PL / SQL

1

Code

CREATE OR REPLACE FUNCTION BuscaNome
  RETURN t_name
 IS 
  t_name VARCHAR(20); 
BEGIN 

  SELECT T.DS_TURMA INTO t_name
   FROM TURMA T WHERE T.CD_TURMA = 13;

 RETURN t_name;
END;

Error:

  

Error: PL / SQL: Compilation unit analysis terminated Error (2.10):   PLS-00320: the declaration of the type of this expression is   incomplete or malformed

    
asked by anonymous 22.01.2018 / 19:18

1 answer

2

In the return of the function declaration you have to put the type, not the variable. In your case, it would be:

CREATE OR REPLACE FUNCTION BuscaNome RETURN VARCHAR IS

This is because the type of variable that will return is VARCHAR.

    
29.08.2018 / 18:42