oracle创建触发器调用含参数存储过程

来源:互联网 发布:union sql 编辑:程序博客网 时间:2024/05/18 17:00

背景:在向数据表中插入数据时调用已定义的存储过程,对插入数据进行xml解析,该存储过程含参数,

解决方法:为插入数据表建立触发器,在触发器中调用存储过程

存储过程:请参见上一篇博客文章  oracle中使用存储过程解析xml字符串

插入语句为:insert into t_xml2,  ‘<item><cpu_name>name1</cpu_name><value>80%</value></item>

触发器建立:

create orreplace triggerTRG_t_PARSE

  beforeinsert ont_xml

  referencing

  foreach row

declare

  -- local variables here

  --pragma autonomous_transaction;--自治事务,子事务可以有commit

begin 

  p_parse(:new.id);  --调用存储过程,传参数:new.id

  --commit;

endTRG_t_PARSE;

原创粉丝点击