0

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

1
  • 1
    Go on add rest of function.. Commented Jan 27, 2021 at 17:15

1 Answer 1

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..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.