SHARE
TWEET

Untitled

a guest Jun 16th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ORA-31011: XML parsing failed
  2. ORA-19202: Error occurred in XML processing
  3. LPX-00244: invalid use of less-than ('<') character (use <)
  4. Error at line 1
  5. 31011. 00000 -  "XML parsing failed"
  6. *Cause:    XML parser returned an error while trying to parse the document.
  7. *Action:   Check if the document to be parsed is valid.
  8.      
  9. create table foo(id int, xml clob, valid int default null);
  10. insert into foo(id,xml) values (1, '<?xml version="1.0"?><root><a foo="b"></a></root>');
  11. insert into foo(id,xml) values (2, '<?xml version="1.0"?><root><a foo="<"></a></root>');
  12. commit;
  13.      
  14. create function is_valid_xml(xml_param clob)
  15. return int
  16. as
  17.   scratch xmltype;
  18. begin
  19.   select xmltype(xml_param) into scratch from dual;
  20.   return 1;
  21. exception
  22.   when others then
  23.     return 0;
  24. end;
  25. /
  26.      
  27. SQL> update foo set valid = is_valid_xml(xml) where valid is null;
  28. 2 rows updated.
  29.  
  30. SQL> select id, valid from foo;
  31. ID | VALID
  32. ----------
  33.  1 |     1
  34.  2 |     0
  35.      
  36. create function my_create_xml(p_clob clob) return xmltype is
  37.   l_retval xmltype;
  38. begin
  39.     select xmltype(p_clob) into l_retval from dual;
  40.     return l_retval;
  41. exception
  42. when others then
  43.   if sqlcode != -31011 then raise;
  44.   else return null;
  45.   end if;
  46. end;
  47. /
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top