这是我试图用来创建触发器的代码:
-- Dumping structure for trigger kavanga_lead.click_links_insert
DROP TRIGGER IF EXISTS `click_links_insert`;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='';
DELIMITER //
CREATE TRIGGER `click_links_insert` AFTER INSERT ON `click_links` FOR EACH ROW BEGIN
INSERT INTO actions_log
(
`uid`,
`table`,
`action`,
`new`
)
VALUES
(
@user_id,
'click_links',
'insert',
concat(NEW.id ,'|', NEW.`contents`, '|', NEW.channel_id, '|', NEW.name, '|', NEW.hidden, '|', if(NEW.prefix_id is null,'',NEW.prefix_id) '|', if(NEW.postfix_id is null,'',NEW.postfix_id))
);
END//
DELIMITER ;
SET SQL_MODE=@OLD_SQL_MODE;
我不断收到错误 (1583) Incorrect parameters in the call to concat
。如果我不使用if(NEW.prefix_id is null,'',NEW.prefix_id)
但只使用NEW.prefix_id
. 但是这个字段可以null
,所以所有concat
的结果都变成null
了to。
所以,问题是我如何IF
在CONCAT
调用中使用语句?