Help with "Expression as an assignment target" error
simple question here, I am writing a function, but I was having trouble setting up my first if statement, my attempt is below, but I keep getting "Expression can not be used as an assignment target" error on the lines "Type := CE;" and "Type :=UG;" Im sure there is a quick fix to this.开发者_运维百科..... anyone know?
CREATE OR REPLACE FUNCTION SCHEMA1."FUNCTION1" ( Id IN VARCHAR2,
term IN VARCHAR2,
Type IN VARCHAR2 default NULL )
RETURN VARCHAR2 IS
BEGIN
IF Type IS NULL
THEN
IF SUBSTR(term,5,6) = 'Q'
THEN
Type := 'CE';
ELSE
Type := 'UG';
END IF;
END IF;
........
Declare a holding variable for use within the function?
CREATE OR REPLACE FUNCTION SCHEMA1."FUNCTION1" ( Id IN VARCHAR2,
term IN VARCHAR2,
Type IN VARCHAR2 default NULL )
RETURN
VARCHAR2
IS
iType VARCHAR2;
BEGIN
iType := Type;
IF iType IS NULL
THEN
IF SUBSTR(term,5,6) = 'Q'
THEN
iType := 'CE';
ELSE
iType := 'UG';
END IF;
END IF;
........
Looks to me like you're passing 'Type' in as an argument and then trying to assign to it. Is your intent to RETURN 'CE'/'UG' based on Term? If so, introduce a new variable or change Type := to RETURN.
精彩评论