XML generation in Oracle8i
Anil, December 21, 2002 - 5:47 am UTC
Hi Tom:
I tried using the xmlgen package in 8i but it failed with this error. Can you please give me a list of steps(checklist) which I need to check. I donot want to blindly increase the size of my shared pool. I just want to findout why this has occured - so I need your help it actually finding the source of the problem.
select xmlgen.getxml('select * from tags') from dual
*
ERROR at line 1:
ORA-04031: unable to allocate 4032 bytes of shared memory ("shared
pool","OracleXMLStoreSYS","joxlod: in ehe","ioc_allocate_pal")
ORA-06512: at "SYS.XMLGEN", line 487
ORA-06512: at "SYS.XMLGEN", line 477
ORA-06512: at line 1
Thanks for your time.
Best Regards,
Anil
December 21, 2002 - 9:01 am UTC
make sure your java pool and shared pool are set large enough (they are not right now)
VINI, June 27, 2003 - 10:58 am UTC
Hi,
I too have a ORA-04031.
I did the "alter system flush shared pool". but still has the problem.
our people doesn't want to change existing sql (for bind variables), and or shutdown the database.
so my problem is :
Is there any other way to refresh the shared memory ?
June 27, 2003 - 12:08 pm UTC
how big is your shared pool
and why won't the developers fix the bugs in their code? make fun of them, maybe they'll get it.
have you tried cursor_sharing?
ORA-04031: unable to allocate 4032 bytes of shared memory ("shared
Yong, June 27, 2003 - 1:22 pm UTC
I encoutered the similar problem on Oracle8i before. The real problem was that the pl/sql package was locked. For example, the package is running and you try to re-compile the package from other tool, then you will get this error. You may find the process to kill the compiling process. You may not be able drop/re-create the package. There is a undocument way to break the lock.
June 27, 2003 - 1:39 pm UTC
umm, no, that won't do that. you'll get a timeout, not an "out of memory"
CHop off
A reader, June 27, 2003 - 3:13 pm UTC
Hi, Tom,
I tried you code, but only got some of the output, the others are chopped of:
DBMS_XMLGEN.GETXML('SELECT*FROMSCOTT.EMP')
------------------------------------------------------------
<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAM
<--------Missing parts
1 row selected.
Only one partial row? Or do I need to do somthing here?
How to get XML data back to the DB?
THanks
June 27, 2003 - 3:49 pm UTC
SQL> set long 500000
or some big number. just a sqlplus setting.
search for
xmlsave
on this site.
how can we insert data into oracle from XML file
A Reader, July 28, 2003 - 6:30 am UTC
hi Tom ...
need ur help Again ...
how can we insert data into oracle from XML file
Thanx
July 28, 2003 - 7:41 am UTC
Re:
a reader, July 29, 2003 - 3:20 am UTC
hii ... Tom ..
we are using 8.1.5 ...
July 29, 2003 - 7:08 am UTC
see otn.oracle.com, goto the xml technology corner. much of the stuff can be loaded into 8i, some of it must run outside of the database.
Why null in fields?
Sasa, August 18, 2003 - 6:54 am UTC
Hi Tom,
I created test case(hope will help).
(it is Oracle 9.2.03)
create table xmltest (id number, xmlpayload xmltype);
Table created.
insert into xmltest(id, xmlpayload)
values(1, xmltype(
'<?xml version="1.0"?>
<ROWSET>
<ROW>
<IDFOBETSTATE>A</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>1</INTERNALORDER>
<INTERNALDESCRIPTION>Bet attempted (not open/valid)</INTERNALDESCRIPTION>
<NAME>Attempted</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>O</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>2</INTERNALORDER>
<INTERNALDESCRIPTION>Bet opened</INTERNALDESCRIPTION>
<NAME>Open</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>C</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>3</INTERNALORDER>
<INTERNALDESCRIPTION>Bet closed(All legs closed - not settled)</INTERNALDESCRIPTION>
<NAME>Closed</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>S</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>4</INTERNALORDER>
<INTERNALDESCRIPTION>Bet settled(Bet is paid out)</INTERNALDESCRIPTION>
<NAME>Settled</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>?</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>5</INTERNALORDER>
<INTERNALDESCRIPTION>Bet undefined(whatever it means)</INTERNALDESCRIPTION>
<NAME>Unknown</NAME>
</ROW>
</ROWSET>'));
1 row created.
commit;
Commit complete.
SELECT
extract(value(d),'ROWSET/ROW/IDFOBETSTATE/text()').getstringVal() as IDFOBETSTATE,
extract(value(d),'ROWSET/ROW/INTERNALORDER/text()').getnumberVal() as INTERNALORDER
FROM xmltest t,
TABLE(XMLSequence(t.xmlpayload.extract('ROWSET/ROW'))) d;
This query shows me correctly 5 records but with the null in the fields.
What am I missing?
Please, help.
August 18, 2003 - 7:31 am UTC
because the rowset is gone by then... always helpful to just dump the query out and see what it is giving you back. I started with "select *" but backed off to just select column_value for showing you what is there:
ops$tkyte@ORA920> SELECT column_value
2 FROM xmltest t,
3 TABLE(XMLSequence(t.xmlpayload.extract('ROWSET/ROW'))) d;
COLUMN_VALUE
-----------------------------------------------------------------------------------------------------------------------------------
<ROW>
<IDFOBETSTATE>A</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>1</INTERNALORDER>
<INTERNALDESCRIPTION>Bet attempted (not open/valid)</INTERNALDESCRIPTION>
<NAME>Attempted</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>O</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>2</INTERNALORDER>
<INTERNALDESCRIPTION>Bet opened</INTERNALDESCRIPTION>
<NAME>Open</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>C</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>3</INTERNALORDER>
<INTERNALDESCRIPTION>Bet closed(All legs closed - not settled)</INTERNALDESCRIPTION>
<NAME>Closed</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>S</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>4</INTERNALORDER>
<INTERNALDESCRIPTION>Bet settled(Bet is paid out)</INTERNALDESCRIPTION>
<NAME>Settled</NAME>
</ROW>
<ROW>
<IDFOBETSTATE>?</IDFOBETSTATE>
<ISACTIVE>-1</ISACTIVE>
<INTERNALORDER>5</INTERNALORDER>
<INTERNALDESCRIPTION>Bet undefined(whatever it means)</INTERNALDESCRIPTION>
<NAME>Unknown</NAME>
</ROW>
<b>so, what you want is:</b>
ops$tkyte@ORA920>
ops$tkyte@ORA920> SELECT
2 extract(value(d),'/ROW/IDFOBETSTATE/text()').getstringVal() as
3 IDFOBETSTATE,
4 extract(value(d),'/ROW/INTERNALORDER/text()').getnumberVal() as
5 INTERNALORDER
6 FROM xmltest t,
7 TABLE(XMLSequence(t.xmlpayload.extract('ROWSET/ROW'))) d;
IDFOBETSTATE INTERNALORDER
--------------- -------------
A 1
O 2
C 3
S 4
? 5
ops$tkyte@ORA920>
It works now
Sasa, August 18, 2003 - 11:01 am UTC
Thanks Tom,
Now works.
How to extract Oracle data into a XML formatted file, ver 9.0.1
Raj, August 21, 2003 - 5:35 pm UTC
Hi Tom,
I have the following problem....
SQL> select dbms_xmlgen.getxml( 'select * from scott.emp' ) from
2 dual;
ERROR:
ORA-01722: invalid number
no rows selected
Could you know what's wrong?
Raj
September 25, 2003 - 10:18 am UTC
I asked Sean Dillon, our local XML guy, to take a look at this and here's what he had to say:
-------
Hiya Raj,
I'm not sure why you're getting this error, but a couple things you can try:
1. Make sure you have the appropriate SELECT grant on SCOTT.EMP.
2. Try the same statement but specify the columns instead of "*". For example, "select empno, ename, job from scott.emp". See what that gives you.
3. Make sure you can use DBMS_XMLGEN.GETXML on a simple table you create:
SQL> create table t( txt varchar2(50), num number );
Table created.
SQL> insert into t values ( 'One', 1 );
1 row created.
SQL> insert into t values ( 'Two', 2 );
1 row created.
SQL> insert into t values ( 'Three', 3 );
1 row created.
SQL> insert into t values ( 'Four', 4 );
1 row created.
SQL> select dbms_xmlgen.getxml( 'select * from t' )
2 from dual;
DBMS_XMLGEN.GETXML('SELECT*FROMT')
--------------------------------------------------------------------------------
<?xml version="1.0"?>
<ROWSET>
<ROW>
<TXT>One</TXT>
<NUM>1</NUM>
</ROW>
<ROW>
<TXT>Two</TXT>
<NUM>2</NUM>
</ROW>
<ROW>
<TXT>Three</TXT>
<NUM>3</NUM>
</ROW>
<ROW>
<TXT>Four</TXT>
<NUM>4</NUM>
</ROW>
</ROWSET>
If you have the appropriate privileges (you can just "select * from scott.emp" logged in as the same user...), and the test above works just dandy, let me know.
CLOB or XMLType
A reader, August 26, 2003 - 9:05 am UTC
Tom,
Which is the better option to store XML data
1)CLOB data type
2)XMLType
When writing(inserting) data to a table, the options I know we have in oracle are
dbms_xmlSave.InsertXML and
dbms_lob.loadfromfile
Which option is the better option to go with?
Thank you
August 26, 2003 - 10:35 am UTC
depends on what you want to do with it (as always)
if you want to have xml functionality -- xmltype makes sense.
if it is just a bit bucket, clob might be good enough.
Is SYS_XMLGEN supported in Oracle 9.2.0
Sap, February 11, 2005 - 3:09 am UTC
Hi Tom,
When i am trying to run a simple query using SYS_XMLGEN, i encountered a small problem, can you help me out with this error.
1* select SYS_XMLGEN(empno) from asg_emp
SQL> /
ERROR:
ORA-31011: XML parsing failed
February 11, 2005 - 8:02 pm UTC
care to share perhaps the data you used?
DBMS_XMLGEN or SYS_XMLGEN??
sap, February 14, 2005 - 7:27 am UTC
Hi Tom,
Which is better option Dnms_xmlgen or Sys_xmlgen?
Or, how can i decide which one to use Dbms_xmlgen or Sys_xmlgen?
February 14, 2005 - 8:37 am UTC
benchmark, as always.
neither is "better", they are different. used in different places.