i wrote the stored procedure:
CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_create_new_task`(
IN _taskName VARCHAR(30),
IN _description VARCHAR(500),
IN _startDate DATETIME,
IN _endDate DATETIME,
IN _lacation VARCHAR(30),
IN _subTo INT
)
BEGIN
INSERT INTO tm_tasks (taskName, description, startDate, endDate, lacation, subTo)
VALUES (_taskName, _description, NULLIF(_startDate,''), NULLIF(_endDate,''), _lacation, _subTo);
END
I run it:
call task_tool.SP_create_new_task('name1 ', 'description1', '', '', 'lacation1', 1);
and got this error:
Error Code: 1292. Incorrect datetime value: '' for column '_startDate' at row 1
why NULLIF() didn't enter Null value to _startDate???
for your convenience, task table query:
CREATE TABLE tm_tasks(
ID INT PRIMARY KEY AUTO_INCREMENT,
taskName VARCHAR(30) NOT NULL,
description VARCHAR(500),
joinDate TIMESTAMP,
startDate DATETIME NULL DEFAULT NULL,
endDate DATETIME NULL DEFAULT NULL,
lacation VARCHAR(30),
subTo INT DEFAULT NULL,
ignoreRow TINYINT(1) DEFAULT 0
);
Thanks!