首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

postgresql 触发器 简介(转)

– 把before for each row的触发器删掉, 再测试插入 : postgres=# drop trigger tg02 on t_ret; DROP TRIGGER postgres=# drop trigger tg2 on t_ret; DROP TRIGGER postgres=# insert into t_ret values(1,’digoal’,now()); NOTICE: 00000: tg01 LOCATION: exec_stmt_raise, pl_exec.c:2840 NOTICE: 00000: tg1 LOCATION: exec_stmt_raise, pl_exec.c:2840 NOTICE: 00000: tg03, after for each row 的触发器函数返回空, 不影响后续的触发器是否被调用. 因为只要表上面发生了真正的行操作, after for each row就会被触发, 除非when条件不满足. (这个后面会讲到) LOCATION: exec_stmt_raise, pl_exec.c:2840 NOTICE: 00000: tg3 LOCATION: exec_stmt_raise, pl_exec.c:2840 NOTICE: 00000: tg04 LOCATION: exec_stmt_raise, pl_exec.c:2840 NOTICE: 00000: tg4 LOCATION: exec_stmt_raise, pl_exec.c:2840 INSERT 0 1 – 有数据插入. 这也说明了before for each statement的返回值为空并不会影响数据库对行的操作. 只有before for each row的返回值会影响数据库对行的操作. postgres=# select * from t_ret ; id | info | crt_time —-+——–+—————————- 1 | digoal | 2013-03-10 16:50:39.551481 (1 row)

02
领券