一個觸發器的例子

create or replace trigger "USREMHR".trg_sq_rule_insert
  before insert on sq_rule_base
  for each row


declare
  temp_rule_id varchar2(10);
  temp_rul_theme_id varchar2(10);
begin

  begin
       temp_rule_id := :new.rule_id;
       temp_rul_theme_id := :new.rul_theme_id;
       insert into sq_result_detail(result_id,result_rul_id,result_thedet_id,result_field_id)
       select
       to_char(sysdate,'yy')||to_char(sysdate,'mm')||trim(to_char(SEQ_SQ_RULE.nextval,'000000')),
       temp_rule_id,the_id,sq_id
       from sq_theme_detail,sq_table
       where the_tablename=sq_tablename
       and sq_fieldyon='Y'
       and theme_id=temp_rul_theme_id;
  end;

end trg_sq_rule_insert;

發佈了41 篇原創文章 · 獲贊 0 · 訪問量 33萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章