On duplicate key do nothing
-
31-10-2019 - |
Question
I am inserting into the following table using LuaSQL with PtokaX API.
CREATE TABLE `requests` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`ctg` VARCHAR(15) NOT NULL,
`msg` VARCHAR(250) NOT NULL,
`nick` VARCHAR(32) NOT NULL,
`filled` ENUM('Y','N') NOT NULL DEFAULT 'N',
`dated` DATETIME NOT NULL,
`filldate` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `nick_msg` (`nick`, `msg`),
UNIQUE INDEX `ctg_msg` (`ctg`, `msg`)
)
COMMENT='Requests from users in any of the categories.'
COLLATE='utf8_general_ci'
ENGINE=MyISAM;
Now, my problem is, when a user(represented by nick
) tries to insert same request again, the UNIQUE
index is checked and the script returns a false. This causes my script to fail and I have to restart the script.
Is there something I can do in the
INSERT ... ON DUPLICATE KEY
command so that it does nothing or at-least does NOT return an error in case ofDUPLICATE KEY
?
Otherwise I'd have to go for updating my dated
field with the new DATETIME
value.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange