Some time ago I've had noticed strange problem with XMLRoot function. I was installing application on production server and I've noticed that code:
SQL> select XMLRoot(xmltype('<a>a</a>'))gives error:
2 from dual;
select XMLRoot(xmltype('<a>a</a>'))WTF, it was running perfectly on development and test environment!
*
Error in line 1:
ORA-00904: "XMLROOT": invalid identifier
Quick search revealed that XMLROOT is function in XDB schema, which was missing in production environment. I've just copies source code for function from test environment and I could proceed further.
After some time, I've decided to check why this function was missing?
Quick search showed that function is created by script ?\demo\schema\order_entry\xdbUtilities.sql
Strange, well documented function is created only when you install demo schemas? Seems that there should be another explanation.
Then I've found that in documentation this function has 2 mandatory attributes, while my code has only one attribute. So there are 2 versions of XMLRoot function:
- SQL function; see documentation
- Simplified version created by demo in XDB schema - this version can be also used in PL/SQL
Conclusion: my original code should look like that:
SQL> select XMLRoot(xmltype('<a>a</a>'), version '1.0', standalone yes)This can run without XMLROOT function in XDB schema.
2 from dual;
XMLROOT(XMLTYPE('<A>A</A>'),VERSION'1.0',STANDALONEYES)
------------------------------------------------------------------------
<?xml version="1.0" standalone="yes"?>
<a>a</a>
Hope this will help someone to save some time.
Cheers,Paweł
--
Related Articles on Paweł Barut blog:
6 comments:
Saved me lots of time. Thanks for posting this.
Thank you for saving my time.
Very helpful for me today
saved me some hours of searching, thanks :-)
I was using without version and standalone parameter but it wasn't working then found your blog, it helped a lot
Post a Comment