2

How can I add parameters with NULL default value for MySQL stored procedure?

4

2 Answers 2

2

According to this answer MySQL does not support true 'default parameters' in functions or stored procedures.

This answer on the same page provides a solution that may work for you.

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

Comments

0

Any query with variable and 'case`:-

BEGIN 
    DECLARE @NullValue:=Null;  
    SELECT 
    CASE WHEN Sum(myField) Is Null 
    THEN @NullValue ELSE Sum(myField)
    END AS Total 
    FROM table_name; 
END
;

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.