title: insert query not working in stored procedure
body: <p>I have an update query that works when run in isolation, but complains when called inside a stored procedure.</p>
  
  <pre><code>mysql&gt; UPDATE `user` SET `password`=COALESCE(NULL, `password`) WHERE `id`=1;
  Query OK, 0 rows affected (0.00 sec)
  Rows matched: 1  Changed: 0  Warnings: 0
  
  
  mysql&gt; CALL updateUser(1, NULL, NULL, '1950-02-05', NULL);
  ERROR 1048 (23000): Column 'male' cannot be null
  </code></pre>
  
  <p>Here's the stored procedure</p>
  
  <pre><code>DELIMITER $$
  CREATE PROCEDURE `updateUser` (IN userId varchar(255), IN password varchar(100), IN male tinyint(1), IN birthday datetime, IN fbId varchar(160))
  BEGIN
      START TRANSACTION;
          UPDATE `user` SET `male` = IFNULL(male, `male`), `password` = IFNULL(password, `password`), `birthday` = IFNULL(birthday, `birthday`) WHERE `id` = userId;
  
          IF fbId IS NOT NULL THEN
              ...
          END IF;
      COMMIT;
  END
  </code></pre>
  
  <p>I have also tried defining the update query using COALESCE instead of IFNULL, but the results were the same. Does anyone have an idea about what's going on and how could I get my procedure working?</p>