gpt4 book ai didi

MySQL插入: Column 'description' cannot be null but there is no column with name 'description'

转载 作者:行者123 更新时间:2023-11-29 18:23:58 27 4
gpt4 key购买 nike

我正在尝试在 MySQL 表上执行 INSERT 语句。表结构如下

CREATE TABLE `charges` (
`sgl_id` int(11) NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
`opportunity_id` int(11) NOT NULL,
`invoice_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`comment` text NOT NULL,
`quantity` float(18,2) NOT NULL,
`rate` float(18,2) NOT NULL,
`subtotal` float(18,2) NOT NULL,
`tax` float(18,2) NOT NULL,
`total` float(18,2) NOT NULL,
`override_rate` tinyint(1) NOT NULL,
`charge_datetime` datetime NOT NULL,
`created_on` datetime NOT NULL,
`modified_on` datetime NOT NULL,
`created_by` int(11) NOT NULL,
`status_id` int(11) NOT NULL,
`sub_status_id` int(11) NOT NULL,
`status_date` date NOT NULL,
`status_user_id` int(11) NOT NULL,
`status_comment` text NOT NULL,
`mf_id` int(11) NOT NULL,
`company_id` int(11) NOT NULL,
`payment_id` int(11) NOT NULL,
`auto_charge` tinyint(1) NOT NULL,
`store_id` int(11) NOT NULL,
`booking_id` int(11) NOT NULL,
`reversal_charge_id` int(11) NOT NULL,
`revenue_reported` tinyint(1) NOT NULL,
`package_product_id` int(11) NOT NULL,
PRIMARY KEY (`sgl_id`),
KEY `sgl_id_idx` (`sgl_id`),
KEY `customer_id_idx` (`account_id`),
KEY `opportunity_id_idx` (`opportunity_id`),
KEY `invoice_id_idx` (`invoice_id`),
KEY `product_id_idx` (`product_id`),
KEY `status_id_idx` (`status_id`),
KEY `quantity_idx` (`quantity`),
KEY `rate_idx` (`rate`),
KEY `tax_idx` (`tax`),
KEY `total_idx` (`total`),
KEY `sub_status_id_idx` (`sub_status_id`),
KEY `mf_id_idx` (`mf_id`),
KEY `override_rate_idx` (`override_rate`),
KEY `created_by_idx` (`created_by`),
KEY `charge_datetime` (`charge_datetime`),
KEY `created_on` (`created_on`,`modified_on`,`status_date`),
KEY `subtotal_idx` (`subtotal`),
KEY `company_id_idx` (`company_id`),
KEY `payment_id_idx` (`payment_id`),
KEY `auto_charge_idx` (`auto_charge`),
KEY `store_id_idx` (`store_id`),
KEY `booking_id_idx` (`booking_id`),
KEY `reversal_charge_id_idx` (`reversal_charge_id`),
KEY `revenue_reported_idx` (`revenue_reported`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT 语句是

INSERT INTO charges (created_on, created_by, status_id, status_date, status_user_id, sub_status_id, account_id, product_id, comment, quantity, rate, subtotal, tax, total, override_rate, charge_datetime, modified_on, company_id, package_product_id) VALUES ('2017-09-21 09:06:27', '510', '7', '2017-09-21', '510', '59', '817350', '2331', 'Adjustment Charge', '-1', '5.00', '-5', '0', '-5', '1', '2017-09-21 09:06:27', '2017-09-21 09:06:28', '51', '0')

我遇到的错误是

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'description' cannot be null

表中没有名为“description”的列,但 MySQL 仍然抛出错误,“description”的值不能为空。

我对触发器的了解不够,但有一个 INSERT 触发器。

CREATE TRIGGER `charges_insert_trigger` AFTER INSERT ON `charges`
FOR EACH ROW BEGIN
DECLARE change_flag,header_id,sgl_trigger_flag int;
DECLARE description, var_name varchar(500);
SET description = "";
SET change_flag = 0;
SET var_name = "";
SET sgl_trigger_flag = (SELECT count(*) FROM system_prefs WHERE prefname='sgl_trigger_flag' AND prefvalue = '1');
IF sgl_trigger_flag <> 0
THEN
IF (SELECT @sgl_user_id IS NULL)
THEN
SET @sgl_user_id = 0;
SET @sgl_user_name = "System User";
END IF; SET var_name = (SELECT name FROM products where sgl_id = NEW.product_id);
SET description = CONCAT("Charge (ID: ",NEW.sgl_id,") for ", var_name," is added");
IF NEW.opportunity_id > 0
THEN

INSERT INTO changes_log_headers(`user_id`, `user_name`, `changelog_table_name`, `type`, `created_on`, `record_id`, `description`,`account_id`) VALUES (@sgl_user_id,@sgl_user_name,'opportunities','update', NOW(), NEW.opportunity_id, description, NEW.account_id);
ELSE
INSERT INTO changes_log_headers(`user_id`, `user_name`, `changelog_table_name`, `type`, `created_on`, `record_id`, `description`, `account_id`, `show_in_accounts`) VALUES (@sgl_user_id,@sgl_user_name,'accounts','update', NOW(), NEW.account_id, description, NEW.account_id, 1);
END IF; END IF;
END

最佳答案

您的表可能与另一个表链接,该表的列名“description”不能为 NULL。

您应该填写该字段

关于MySQL插入: Column 'description' cannot be null but there is no column with name 'description' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46345629/

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