문제

I am trying to create a fucntion that will read in the value of a column, that is either "H", "C" or "N" and return "Hot", "Cold" or "None", but the case statement i have written keeps casuing this error:

Error at line 5: PL/SQL: Statement ignored

Here is my code, i'm not sure what i'm doing wrong, and the error is typically vague.

CREATE OR REPLACE FUNCTION refreshment(
code IN string)
RETURN STRING IS
BEGIN
RETURN(
CASE code
WHEN "H" THEN "Hot"
WHEN "C" THEN "Cold"
WHEN "N" THEN "None"
END
);
END;
도움이 되었습니까?

해결책

First, string is not a valid date type. You need varchar2 instead. Second, strings are delimited by single quotes not double quotes.

It would appear, therefore, that you want

CREATE OR REPLACE FUNCTION refreshment( p_code IN VARCHAR2 )
  RETURN VARCHAR2
IS
BEGIN
  RETURN CASE p_code
           WHEN 'H' THEN 'Hot'
           WHEN 'C' THEN 'Cold'
           WHEN 'N' THEN 'None'
         END;
END;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top