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;