我有一个表需要两个不同的当前时间。 首先,我有一个插入过程,用于插入actionnumber、msgSentFrom_F_ID、msgSentTo_M_ID 和sentDate。 其次,更新respondDate的更新过程。 我的问题是,当我更新respondDate时,sentDate将更新为我更新respondDate时的同一时间。我哪里做错了? (我的目的是我希望发送日期是我插入时的当前时间,以及我更新响应日期时的另一个当前时间。)
CREATE TABLE IF NOT EXISTS actions (
actionnumber INT AUTO_INCREMENT PRIMARY KEY,
msgSentFrom_F_ID INT,
msgSentTo_M_ID INT,
sentDate TIMESTAMP,
respondDate TIMESTAMP NULL,
FOREIGN KEY (msgSentFrom_F_ID)
REFERENCES femaleUsers(femaleuserId)
FOREIGN KEY (msgSentTo_M_ID)
REFERENCES maleUsers(maleuserId)
);
DELIMITER //
create procedure (param_F_ID INT,param_M_ID INT,Sdate TIMESTAMP)
BEGIN
INSERT INTO actions (msgSentFrom_F_ID, msgSentTo_M_ID, sentDate)
VALUES (param_F_ID,param_M_ID,Now());
END; //
DELIMITER ;
CALL insert_actions ('5','5',NOW());
DELIMITER //
create procedure update_respondDate (param_ActionNum INT,
param_respondDate TIMESTAMP)
BEGIN
UPDATE actions set respondDate = param_respondDate
WHERE actionnumber = param_ActionNum;
END; //
DELIMITER ;
CALL update_respondDate('6',NOW());
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
听起来您禁用了系统变量
explicit_defaults_for_timestamp。 文档解释了此结果: p>由于
sentDate是表中的第一个TIMESTAMP列,因此每当您对该行进行任何更改时,它都会自动设置为当前时间。