I have a stored procedure
CREATE PROCEDURE `DeleteAttachmentsByIDs`(IN p_ids nvarchar(1024), IN p_modifiedBy varchar(100), IN p_modifiedDate datetime)
BEGIN
update attachments set
`IsDeleted` = 1
, `ModifiedBy` = p_modifiedBy
, `ModifiedDate` = p_modifiedDate
where
id IN (p_ids);
END
Now I called with
CALL `DeleteAttachmentsByIDs`('12479,12480,12481', 'admin', '2019-04-02 15:32:30.558178')
And it comes the error
Error Code: 1292. Truncated incorrect DOUBLE value: '12479,12480,12481'
The create table command for attachments table is
CREATE TABLE `attachments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ObjectID` int(11) DEFAULT NULL,
`ObjectName` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`Category` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`ContentType` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`ContentLength` bigint(20) DEFAULT NULL,
`FileName` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`Data` longblob,
`Description` varchar(500) CHARACTER SET utf8 DEFAULT NULL,
`CreatedBy` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`CreatedDate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ModifiedBy` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`ModifiedDate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`IsDeleted` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Index1` (`id`,`ObjectID`,`ObjectName`,`IsDeleted`)
) ENGINE=InnoDB AUTO_INCREMENT=12482 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
I think this may be caused by the 'in' condition which need array, however string is passed in. I think I need to split the string into array to make the 'in' works. Is that correct and how I can do it?