在trigger中用 “
execute procedure ... into 非触发字段 ” 实现赋值给字段。
例子如下:
create table temp_trig
(a serial,
b integer,
c integer);
(a serial,
b integer,
c integer);
CREATE PROCEDURE output_by_input(v_input integer) RETURNING integer;
RETURN v_input;
END PROCEDURE;
RETURN v_input;
END PROCEDURE;
drop trigger tr_tmp_trig_i ;
create trigger tr_tmp_trig_i insert on temp_trig
referencing new as new
for each row
(
execute procedure output_by_input(new.a) into c
);
referencing new as new
for each row
(
execute procedure output_by_input(new.a) into c
);
insert into temp_trig (b) values (2);
本文介绍了一种在数据库中使用触发器结合存储过程来为表中的特定字段赋值的方法。通过创建一个简单的表与存储过程,并设置插入触发器,演示了如何将存储过程的返回值赋给目标字段。
1692

被折叠的 条评论
为什么被折叠?



