Quantcast
Channel: Is it possible to have a default parameter for a mysql stored procedure? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Dive50 for Is it possible to have a default parameter for a mysql stored procedure?

$
0
0

We worked around this limitation by adding a simple IF statement in the stored procedure. Practically we pass an empty string whenever we want to save the default value in the DB.

CREATE DEFINER=`test`@`%` PROCEDURE `myProc`(IN myVarParam VARCHAR(40))BEGIN  IF myVarParam = '' THEN SET myVarParam = 'default-value'; END IF;  ...your code here...END

Viewing all articles
Browse latest Browse all 7

Trending Articles