Code Listing 7: Updating or creating the XML document
--Note that the global package variable g_sml_ns contains
--namespace URI: 'xmlns="http://www.decode.com/schemas/sml/2"'
procedure hlq_ins_survey_xml(p_xml in out nocopy clob)
is
v_result boolean;
v_xml xmltype := xmltype.createxml(p_xml);
v_survey_code varchar2(20);
v_language_code varchar2(5);
v_dockey hlq_dockey_ty;
begin
v_survey_code := v_xml.extract('/sml/survey/@code',g_sml_ns).getStringVal();
v_language_code := v_xml.extract('/sml/survey/@language',g_sml_ns).getStringVal();
v_dockey := hlq_dockey.hlq_get_survey_dockey(v_survey_code,v_language_code);
if (v_dockey is null) then
v_result := dbms_xdb.createResource(hlq_path.hlq_get_survey_path
(v_survey_code, v_language_code)
,v_xml);
else
update hlq_survey_xml_dtb x
set value(x) = v_xml
where rowid = v_dockey.get_xdb_rowid
;
end;
end;
|