Code Listing 4: Creating an insert trigger

create or replace trigger hlq_survey_xml_dtb_air_trg
after insert on hlq_survey_xml_dtb
for each row
declare
  v_xml xmltype := :new.sys_nc_rowinfo$;
  v_survey_code    varchar2(20);
  v_language_code  varchar2(5);
  v_sml_ns         varchar2(60) := hlq_sml.hlq_get_sml_ns;

begin
  v_survey_code   := v_xml.extract('/sml/survey/@code',v_sml_ns).getStringVal();
  v_language_code := v_xml.extract('/sml/survey/@language',v_sml_ns).getStringVal();

  -- validate against XML schema
  hlq_xsd.hlq_validate_survey(v_xml,v_survey_code);

  -- check reference integrity (e.g. survey->question)
  hlq_integrity.hlq_check_survey_integrity(v_xml,v_survey_code,v_language_code);

  insert into hlq_survey_link_tb
    (survey_code, language_code, survey_xdburi, survey_dtb_rowid, created_timestamp)
 
  values
    (v_survey_code, v_language_code,     
     XDBUriType(hlq_path.hlq_get_survey_path(v_survey_code,v_language_code))
    ,rowidtochar(:new.rowid), sysdate);
end;
/
show errors

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy