Error running Function in PL/SQL

Asked

Viewed 72 times

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

1 answer

2


In the function declaration Return 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.