i'm using oracle 8.1.7. correct me if i'm wrong but xmlgen is supported only by 9.x, isn't?
i first tried to output them on the comand line but it return 15++ for some reason. any idea?
cheers
here's the code
-------------------------
declare
queryCtx DBMS_XMLquery.ctxType;
result CLOB;
begin
-- set up the query context...!
queryCtx := DBMS_XMLQuery.newContext('select NAME from LOCATION');
-- get the result..!
result := DBMS_XMLQuery.getXML(queryCtx);
-- Now you can use the result to put it in tables/send as messages..
printClobOut(result);
DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
end;
---------------------------
You should end your code with semicolon and carriage return to let sql*plus know that you've finished entering command and it's time to execute it. In you script it should be
set pages 0
set long 100000
select xmlgen.getxml('select NAME from LOCATION') from dual;
--here is a blank line, don't forget
sorry, for that. I didn't mean to waste your time with this typo.
wow, that did something. but i believe i need to install something to make this run. cannot find the oracleXMLStore. But again. where would it save the generated xml file? in the same directory?
-----------------------------------------
SQL> @c:\MakeLocXML3.sql
select xmlgen.getxml('select NAME from LOCATION;') from
*
ERROR at line 1:
ORA-29540: class OracleXMLStore does not exist
ORA-06512: at "ADMINUSER.XMLGEN", line 487
ORA-06512: at "ADMINUSER.XMLGEN", line 477
ORA-06512: at line 1
-----------------------------------------
You should install java. In 8.1.6 you may just run initjvm.sql, but for 8.1.7 it's quite complex procedure (described somewhere at metalink), so it would be better to install it as a part of database installation. As for storing a file, the answer is NOWHERE. It just outputs the result to sql*plus screen. If you need to store it to a file, use SPOOL command. You may also need to add more commands to prevent plus from echoing commands and printing some other unuseful for your case information:
set feedback off
set serverout off
set termout off
The above page says: "This package is similar to the DBMS_XMLQUERY package, except that it is written in C and compiled into the kernel. This package can only be run in the database."
_____________________________________
SQL> @c:\makeLocXML3.SQL
<?xml version = '1.0'?>
<ERROR>oracle.xml.sql.OracleXMLSQLException: ORA-00911: invalid character
</ERROR>
_____________________________________
my code:
_____________________________________
set pages 0
set long 100000
select xmlgen.getxml('select NAME from HC_LOCATION;') from dual;
_____________________________________
cheers. I'll check the documentation on spooler. thanks.
I'm not from russia at all. Still though I like it. my lovely country is more captialized but tremendousl tiny compared to russia (well, which country isn't so COMPARED to Russia)
Hi all,
I have a problem. I read your news on xml file generation.
I have tried to use xmlgen and dbms_xmlquery, but I haven't found a way to set more than one attribute for a node.
For example, I want to have:
<Contract IDContract = 'XXX' IDCustomer = 'YYY'>
But I don't know to to get this.
(Another problem I have is to write the <!DOCTYPE...> tag in the resulting xml file).
Any kind of suggestion on these two problems will be particularly appreciated.
Thank you in advance for any kind of help!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.