gpt4 book ai didi

MySQL:列数与第 1 行的值数不匹配

转载 作者:行者123 更新时间:2023-11-29 03:07:25 24 4
gpt4 key购买 nike

<分区>

对于冗长的代码,我深表歉意,但我正在尝试创建一个审计表(称为 aud_candles),它是“蜡烛”的副本,但具有新的唯一键 aud_can_id。在对“蜡烛”进行更新之前,我希望触发器将该行的当前状态保存在“aud_candles”中。

Target Server Type    : MySQL
Target Server Version : 50165
File Encoding : utf-8

Date: 11/07/2012 23:05:38 PM
*/

SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for `candles`
-- ----------------------------
DROP TABLE IF EXISTS `candles`;
CREATE TABLE `candles` (
`can_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`can_name` varchar(255) NOT NULL,
`can_description` varchar(1024) NOT NULL,
`can_dye_id` int(10) unsigned NOT NULL,
`can_snt_id` int(10) unsigned NOT NULL,
`can_wick_id` int(10) unsigned NOT NULL,
`can_wax_id` int(10) unsigned NOT NULL,
`can_retail_cost` float(10,2) NOT NULL,
`can_materials_cost` float(10,2) NOT NULL,
`can_dye_used` float(10,2) NOT NULL,
`can_snt_used` float(10,2) NOT NULL,
`can_wick_used` float(10,2) NOT NULL,
`can_wax_used` float(10,2) NOT NULL,
`can_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`can_id`),
KEY `idx_candles_dyes_id` (`can_dye_id`) USING BTREE,
KEY `idx_candles_scents_id` (`can_snt_id`) USING BTREE,
KEY `idx_candles_wax_id` (`can_wax_id`) USING BTREE,
KEY `fk_candles_wick_id` (`can_wick_id`),
CONSTRAINT `fk_candles_dye_id` FOREIGN KEY (`can_dye_id`) REFERENCES `dyes` (`dye_id`),
CONSTRAINT `fk_candles_scent_id` FOREIGN KEY (`can_snt_id`) REFERENCES `scents` (`snt_id`),
CONSTRAINT `fk_candles_wax_id` FOREIGN KEY (`can_wax_id`) REFERENCES `wax` (`wax_id`),
CONSTRAINT `fk_candles_wick_id` FOREIGN KEY (`can_wick_id`) REFERENCES `wicks` (`wic_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

delimiter ;;
CREATE TRIGGER `trg_audit_update_candles` BEFORE UPDATE ON `candles` FOR EACH ROW BEGIN
INSERT INTO aud_candles
(can_id,
can_name,
can_description,
can_dye_id,
can_snt_id,
can_wick_id,
can_wax_id,
can_materials_cost,
can_retail_cost,
can_updated)
VALUES
(OLD.can_id,
OLD.can_name,
OLD.can_description,
OLD.can_dye_id,
OLD.can_snt_id,
OLD,can_wick_id,
OLD.can_wax_id,
OLD.can_materials_cost,
OLD.can_retail_cost,
OLD.can_updated);
END;
;;
delimiter ;

-- ----------------------------
-- Records of `candles`
-- ----------------------------
BEGIN;
INSERT INTO `candles` VALUES ('1', 'Test Name', 'Test Description', '12', '10', '102', '1', '0.00', '0.00', '5', '25.00', '15.00', '500.00', '2012-11-07 13:29:02');
COMMIT;


DROP TABLE IF EXISTS `aud_candles`;
CREATE TABLE `aud_candles` (
`aud_can_id` int(11) NOT NULL AUTO_INCREMENT,
`can_id` int(10) unsigned NOT NULL,
`can_name` varchar(255) CHARACTER SET latin1 NOT NULL,
`can_description` varchar(1024) CHARACTER SET latin1 NOT NULL,
`can_dye_id` int(10) unsigned NOT NULL,
`can_snt_id` int(10) unsigned NOT NULL,
`can_wick_id` int(10) unsigned NOT NULL,
`can_wax_id` int(10) unsigned NOT NULL,
`can_retail_cost` float(10,2) NOT NULL,
`can_materials_cost` float(10,2) NOT NULL,
`can_dye_used` float(10,2) NOT NULL,
`can_snt_used` float(10,2) NOT NULL,
`can_wick_used` float(10,2) NOT NULL,
`can_wax_used` float(10,2) NOT NULL,
PRIMARY KEY (`aud_can_id`),
KEY `idx_candles_dyes_id` (`can_dye_id`) USING BTREE,
KEY `idx_candles_scents_id` (`can_snt_id`) USING BTREE,
KEY `idx_candles_wax_id` (`can_wax_id`) USING BTREE,
KEY `fk_candles_wick_id` (`can_wick_id`),
CONSTRAINT `fk_aud_candles_dye_id` FOREIGN KEY (`can_dye_id`) REFERENCES `dyes` (`dye_id`),
CONSTRAINT `fk_aud_candles_scent_id` FOREIGN KEY (`can_snt_id`) REFERENCES `scents` (`snt_id`),
CONSTRAINT `fk_aud_candles_wax_id` FOREIGN KEY (`can_wax_id`) REFERENCES `wax` (`wax_id`),
CONSTRAINT `fk_aud_candles_wick_id` FOREIGN KEY (`can_wick_id`) REFERENCES `wicks` (`wic_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8




SET FOREIGN_KEY_CHECKS = 1;

UPDATE candles set can_name = 'Test Name 2' WHERE can_id = 1;

执行更新时我收到:

错误

Column count doesn't match value count at row 1

如果我删除触发器一切正常,那么它一定与触发器相关吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com