我想创建一个逻辑(if-else)MySQL触发器。我正在使用PHPMyAdmin GUI创建一个触发器。但是当我试图保存触发器时,我遇到了SQL错误。
这是我想要遇到触发器的代码:
DECLARE id integer;
DECLARE changelogid integer;
SET @id = INSERT INTO `test_assessment_data_changelog`(assignment_id,
parameter_id, assessor_id, assessment_value)
values(1, 1, 101, 'new');
SET @changelogid = SELECT `id` FROM `test_assesseement_data`
WHERE `changelog_id` = @id;
IF @changelogid=null THEN
UPDATE `test_assesseement_data`
SET `value` = 'new' WHERE `changelog_id` = @changelogid;
ELSE
INSERT INTO `test_assesseement_data`(`changelog_id`,
`value`) values(@changelogid, 'new');
END IF;
由于