I have a function with 4 parameters and for example if I set null/empty value for the first parameter which is type DATE I get the result 2 instead of 1.
SET @p0=''; SET @p1=''; SET @p2=''; SET @p3=''; SELECT `MY_FN`(@p0, @p1, @p2, @p3) AS `MY_FN`;
My code:
BEGIN
IF PARAM1_DATE IS NULL or PARAM1_DATE='' THEN
SET @STATUS = 1;
ELSE
SET @STATUS = 2;
END IF;
RETURN @STATUS;
END
I've tried also ISNULL(NULLIF(PARAM1_DATE,'') same result
asked Jan 27, 2021 at 17:07
BlueDotRo
1011 gold badge2 silver badges9 bronze badges
-
1Go on add rest of function..P.Salmon– P.Salmon2021年01月27日 17:15:48 +00:00Commented Jan 27, 2021 at 17:15
1 Answer 1
the validation of parameters OCCURS BEFORE function code is executed you need to make sure a valid date (if that's what param1_date datatype is) is passed in the call to the function. if you want to pass any old rubbish then define as char and test in function..
answered Jan 27, 2021 at 17:24
P.Salmon
17.7k2 gold badges14 silver badges22 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-sql