Page 1 of 1

Stored Procedure Optional Parameters

Posted: Tue May 18, 2010 12:00 pm
by dhui

Code: Select all

DELIMITER //
CREATE PROCEDURE InsertUserData(IN uEmail VARCHAR(300), IN uPass VARCHAR(60), IN uName TEXT)
BEGIN
	INSERT INTO user (email, pass, name)
	VALUE (uEmail, uPass, uName);  //How do I get it so that it will enter null for uName if no name was given as a parameter?
END //
DELIMITER ;
I am new to mysql stored procedures. Is there a way to set a parameter value to NULL unless the parameter is sent a value? See above create procedure to see what I am trying to do.

Thanks.

Re: Stored Procedure Optional Parameters

Posted: Tue May 18, 2010 12:23 pm
by mikosiko
parameters (IN/OUT or INOUT) cannot be omitted when you CALL a procedure no matter what value the parameter has.