CASE error function

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
  

Poston Wed, 07 Jan 2009 12:43 pm

In creating the function below, occurs this error, can anyone help me, please.

PLS-00103: Encountered the symbol \"CASE\" when expecting one of the following:
Code: Select all
CREATE OR REPLACE FUNCTION       TESTEFUNCAO (
                          CONTA IN INTEGER,
                          TIPO IN VARCHAR2
                        ) RETURN VARCHAR2 IS


RETORNO VARCHAR2(50);

BEGIN

CASE TIPO
  WHEN 'BANCO'
  THEN
        SELECT CODIGO
        INTO RETORNO
        FROM TABELA
        WHERE CODIGOCONTA = CONTA;

  WHEN 'MOEDA'
  THEN
        SELECT CODIGO
        INTO RETORNO
        FROM TABELA
        WHERE CODIGOCONTA = CONTA;

END CASE;
RETURN(RETORNO);

END;
pmv1980
Location: Recife

Poston Wed, 07 Jan 2009 1:09 pm

dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered

Poston Wed, 07 Jan 2009 1:40 pm

Try
Code: Select all
CREATE OR REPLACE FUNCTION       TESTEFUNCAO (
                          CONTA IN INTEGER,
                          TIPO IN VARCHAR2
                        ) RETURN VARCHAR2 IS


RETORNO VARCHAR2(50);

BEGIN

if TIPO = 'BANCO' THEN
        SELECT CODIGO
        INTO RETORNO
        FROM TABELA
        WHERE CODIGOCONTA = CONTA;

elsif 'MOEDA' THEN
        SELECT CODIGO
        INTO RETORNO
        FROM TABELA
        WHERE CODIGOCONTA = CONTA;

end if;
RETURN(RETORNO);

END;
NaPraia
Location: Floripa - SC

Poston Fri, 09 Jan 2009 12:04 am

at the end of the code takes the case.

Exchange END CASE;

by END;

I believe solves the problem of error that is occurring.
edixsantos
Location: Osasco


  • See also
    Replies
    Views
    Last Post


Return to PL/SQL

Who is online

Users browsing this forum: No registered users and 12 guests