我用一个参数创建了一个存储过程。我做了一个触发器来调用存储过程。更改表(device_session1)的列值时触发调用存储过程。如果is_active更新为“否”,则触发调用存储过程。我在存储过程中传递了该列值,然后过程将其打印出来,但是当我更新列值时,它给出了错误。
表格-
CREATE TABLE `device_session1` (
`id` varchar(75) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
`is_active` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
PRIMARY KEY (`id`));
insert into device_session1(id,is_active) values ('11','YES');
触发-
Delimiter $$
create trigger after_device_session_update
after update on device_session1
For Each Row
BEGIN
IF (NEW.is_active="NO") THEN
SET @session_id = new.id;
call new_procedure1(@session_id);
END IF;
END;
Delimiter;
存储过程-
CREATE PROCEDURE `new_procedure1`(IN id VARCHAR(50))
BEGIN
select concat('id : ',id);
END