英文:
Mysql UPDATE: nullable column gives error although there is a value
问题
SQL怪异!我正在使用MySQL 8数据库,并向表发送了一个更新语句:
UPDATE katalog
SET katalog_status_id = '1',
lieferantennr = '510181',
artikelnummer = '12345678',
artikelbeschreibung = 'dgdfgdfgdfg',
artikelbeschreibung_en = '',
kommentar = 'test test ',
kategorie_a = '910',
kategorie_b = '270',
datum_aenderung = '2023-06-15 14:30:42'
WHERE catalog_id = '21302'
出现了两个问题:
我收到了以下错误消息:
[2023-06-15 14:32:10] [23000][1048] Column 'datum_aenderung' cannot be null
更奇怪的是,列"datum_aenderung" 可以 为空,而且我已经有包含此列的空数据集。
起初,我以为这里可能有一些框架问题,所以我尝试在控制台中直接执行SQL语句(使用PhpStrom作为IDE),但我仍然收到此错误消息。
我忽略了什么?
英文:
SQL weirdness! I am using a mysql 8 db and send an update statement to a table
UPDATE katalog
SET katalog_status_id = '1',
lieferantennr = '510181',
artikelnummer = '12345678',
artikelbeschreibung = 'dgdfgdfgdfg',
artikelbeschreibung_en = '',
kommentar = 'test test ',
kategorie_a = '910',
kategorie_b = '270',
datum_aenderung = '2023-06-15 14:30:42'
WHERE catalog_id = '21302'
Two problems:
I get the error message:
[2023-06-15 14:32:10] [23000][1048] Column 'datum_aenderung' cannot be null
and even weirder the column datum_aenderung can be null and I already have datasets containing null for this column.
First I thought I have some framework weirdness here so I tried the sql statement directly in the console (using PhpStrom as IDE), but I still get this error message.
What am I overlooking?
答案1
得分: 1
可能是由于控制katalog表更新操作的触发器导致的。如果存在该触发器,请尝试禁用它。
请注意,您应该检查为什么存在该触发器,它可能对该表是必要的,并且框架添加该触发器可能有原因。
英文:
It might be because of a trigger that is controlling the update operation of the katalog table. Try disabling that trigger if it exists.
Notice that you should check why that trigger is there, it might be necessary to have it on that table, and there might be a reason that the framework added that trigger.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论