Maybe a bug? using DBMS_XMLGen.ctxHandle;
Hi all, I use a Oracle 10g Database, and i don't know if the following is a bug or i have done something wrong.
I am trying:
CREATE OR REPLACE PROCEDURE MAIN.PRUEBA_XML IS
v_xml clob;
v_ctx DBMS_XMLGen.ctxHandle;
doc xmldom.DOMDocument;
BEGIN
DBMS_LOB.CreateTemporary(v_xml,TRUE);
v_ctx := DBMS_XMLQuery.newContext('Select * from TEST');
v_xml := DBMS_XMLGen.GetXML(v_ctx); -- CRASHES HERE ORA 19019
dbms_xslprocessor.clob2file (v_xml, 'TEMP_DIR', 'XSL_TEST.xml');
dbms_lob.freetemporary(v_xml);
END PRUEBA_XML
And it crashes in the line:
v_xml := DBMS_XMLGen.GetXML(v_ctx);
with an ORA 19019 Error,
but the command 'Select * from TEST' is Ok, bacause i tested on Toad.
Can someone tell how to solve this or if maybe it's a bug?
i am doing this:
CREATE OR REPLACE PROCEDURE SIGADMIN.PRUEBA_XML_XSL IS
queryCtx dbms_xmlquery.ctxType;
result CLOB;
BEGIN
queryCtx := dbms_xmlquery.newContext(
'SELECT TEST_COAPI "COAPI"
, TEST_DNAPI "DNAPI"
FROM TEST'
dbms_xmlquery.setRowTag(
queryCtx
, 'MODULO'
dbms_xmlquery.setRowSetTag(
queryCtx
, 'MODULOS'
DBMS_XMLQUERY.setencodingtag (v_queryctx, 'ISO-8859-1');
result := dbms_xmlquery.getXml(queryCtx);
dbms_xmlquery.closeContext(queryCtx);
dbms_xslprocessor.clob2file (result, 'TEMP_DIR', 'PRUEBA_XML_XSL.xml');
dbms_lob.freetemporary(result);
END
And this works fine for me,
but i have another thing to solve, and that's, ¿how to "delete" the num attribute?,
any idea would be appreciated :)
<?xml version="1.0" encoding="ISO-8859-1"?>
<MODULOS>
<MODULO num="1">
<COAPI>PES</COAPI>
<DNAPI>Consultas Pesetas</DNAPI>
</MODULO>
<MODULO num="2">
<COAPI>ACC</COAPI>
<DNAPI>Control de Acceso</DNAPI>
</MODULO>
<MODULO num="3">
<COAPI>ADM</COAPI>
<DNAPI>Administración</DNAPI>
</MODULO>
</MODULOS>
Similar Messages
-
How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
Hi,
I do generate XML-Files by using DBMS_XMLGEN with output by UTL_FILE
but it seems, the xml-Datafile I get on end is not really UTF-8 encoding
( f.ex. cannot verifying it correct in xmlspy )
my dbms is
NLS_CHARACTERSET = WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_RDBMS_VERSION = 10.2.0.1.0
I do generate it in this matter :
declare
xmldoc CLOB;
ctx number ;
utl_file.file_type;
begin
-- generate fom xml-view :
ctx := DBMS_XMLGEN.newContext('select xml from xml_View');
DBMS_XMLGEN.setRowSetTag(ctx, null);
DBMS_XMLGEN.setRowTag(ctx, null );
DBMS_XMLGEN.SETCONVERTSPECIALCHARS(ctx,TRUE);
-- create xml-file:
xmldoc := DBMS_XMLGEN.getXML(ctx);
-- put data to host-file:
vblob_len := DBMS_LOB.getlength(xmldoc);
DBMS_LOB.READ (xmldoc, vblob_len, 1, vBuffer);
bHandle := utl_file.fopen(vPATH,vFileName,'W',32767);
UTL_FILE.put_line(bHandle, vbuffer, FALSE);
UTL_FILE.fclose(bHandle);
end ;
maybe while work UTL_FILE there is a change the encoding ?
How can this solved ?
Thank you
Norbert
Edited by: astramare on Feb 11, 2009 12:39 PM with database charsetsMarco,
I tryed to work with dbms_xslprocessor.clob2file,
that works good,
but what is in this matter with encoding UTF-8 ?
in my understandig, the xmltyp created should be UTF8 (16),
but when open the xml-file in xmlSpy as UTF-8,
it is not well ( german caracter like Ä, Ö .. ):
my dbms is
NLS_CHARACTERSET = WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_RDBMS_VERSION = 10.2.0.1.0
-- test:
create table nh_test ( s0 number, s1 varchar2(20) ) ;
insert into nh_test (select 1,'hallo' from dual );
insert into nh_test (select 2,'straße' from dual );
insert into nh_test (select 3,'mäckie' from dual );
insert into nh_test (select 4,'euro_€' from dual );
commit;
select * from nh_test ;
S0 S1
1 hallo
1 hallo
2 straße
3 mäckie
4 euro_€
declare
rc sys_refcursor;
begin
open rc FOR SELECT * FROM ( SELECT s0,s1 from nh_test );
dbms_xslprocessor.clob2file( xmltype( rc ).getclobval( ) , 'XML_EXPORT_DIR','my_xml_file.xml');
end;
( its the same when using output with DBMS_XMLDOM.WRITETOFILE )
open in xmlSpy is:
<?xml version="1.0"?>
<ROWSET>
<ROW>
<S0>1</S0>
<S1>hallo</S1>
</ROW>
<ROW>
<S0>2</S0>
<S1>straޥ</S1>
</ROW>
<ROW>
<S0>3</S0>
<S1>m㢫ie</S1>
</ROW>
<ROW>
<S0>4</S0>
<S1>euro_</S1>
</ROW>
</ROWSET>
regards
Norbert -
XML File Generation Issues using DBMS_XMLGEN
Hi,
I am using DBMS_XMLGEN package in a stored procedure to generate an XML file on Oracle 10 G R2 .But, the problem is the format in which the file is generated.
CREATE OR REPLACE TYPE "state_info" as object (
"@product_type" Number
CREATE OR REPLACE TYPE prod_tab as TABLE OF "state_info";
CREATE OR REPLACE TYPE state_t as object (
"state_code" CHAR(2),
"state_info" prod_tab
CREATE OR REPLACE PROCEDURE get_xml_serviced_state (p_clob OUT clob)
IS
v_xmlctx DBMS_XMLGEN.ctxhandle;
v_str VARCHAR2 (1000);
BEGIN
v_str := 'SELECT state_t(a.st_cd,CAST(MULTISET(select veh_type_id from svcd_st where st_cd =a.st_cd)as prod_tab)) as "state_info"
from svcd_st a where a.st_cd in (select distinct st_cd from svcd_st) group by a.st_cd having count(*)>=1';
v_xmlctx := DBMS_XMLGEN.newcontext (v_str);
DBMS_XMLGEN.setrowsettag (v_xmlctx,'serviced_state');
DBMS_XMLGEN.setrowtag (v_xmlctx,NULL);
p_clob := DBMS_XMLGEN.getxml (v_xmlctx);
printclobout(p_clob);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
RAISE;
END;
SHOW ERRORS
Output :
<serviced_state>
<state_info state_code="VA">
<state_info>
<state_info product_type="2"/>
<state_info product_type="5"/>
<state_info product_type="9"/>
</state_info>
</state_info>
<state_info state_code="AB">
<state_info>
<state_info product_type="2"/>
<state_info product_type="5"/>
<state_info product_type="9"/>
</state_info>
</state_info>
</serviced_state>
Required it in below format:
<serviced_state>
<state_info state_code="VA">
<state_info product_type="2"/>
<state_info product_type="5"/>
<state_info product_type="9"/>
</state_info>
<state_info state_code="AB">
<state_info product_type="2"/>
<state_info product_type="5"/>
<state_info product_type="9"/>
</state_info>
</serviced_state>
I just need to put in all the rows under one single tag.Appreciate your early responses.
Thanks.Your wanted XML output is NOT VALID...(try it yourself on http://tools.decisionsoft.com/schemaValidate/)
-
Using dbms_xmlgen with a CAST statement
The following code populates a plsql collection and then attempts to select from it using dbms_xmlgen.
the following error results --
DECLARE
ERROR at line 1:
ORA-19206: Invalid value for query or REF CURSOR parameter
ORA-06512: at "SYS.DBMS_XMLGEN", line 83
ORA-06512: at line 56
The query is correct as the commented out select at end of block works fine.
Can dbms_xmlgen be used in such a way and if not is there a workaround.
Thanks
DECLARE
types declared on the database
create or replace type bus_tab_obj AS object
( BUSINESS_MODEL_ID NUMBER(10)
,BUSINESS_MODEL_VER_NO NUMBER(5)
,BUSINESS_MODEL_NAME VARCHAR2(30));
create or replace TYPE bus_table AS TABLE of bus_tab_obj;
package level variable bus_table_recs in package get_values_pkg
myxml sys.xmltype;
queryCtx DBMS_XMLGen.ctxhandle;
BEGIN
-- initialise and delete
get_values_pkg.bus_table_recs := bus_table(NULL,NULL,NULL);
get_values_pkg.bus_table_recs.DELETE;
-- select some records to put in the collection
for x in ( select BUSINESS_MODEL_ID
,BUSINESS_MODEL_VER_NO
,BUSINESS_MODEL_NAME
from BRK_BUSINESS_MODEL )
LOOP
get_values_pkg.bus_table_recs.extend;
get_values_pkg.bus_table_recs := bus_table(bus_tab_obj(x.business_model_id
,x.business_model_ver_no
,x.business_model_name));
END LOOP;
-- retrieve the records from the collection as xml
queryCtx := DBMS_XMLGen.newContext('select a.business_model_name data from THE ( select cast( get_values_pkg.bus_table_recs as bus_table ) from dual ) a order by data');
dbms_xmlgen.setMaxRows(queryCtx,1);
myxml := DBMS_XMLGen.getXMLType(queryCtx);
dbms_output.put_line(myxml.extract('/*').getStringVal());
this works!
for x in ( select a.business_model_name data
from THE ( select cast( get_values_pkg.bus_table_recs as bus_table ) from dual ) a
order by data )
loop
dbms_output.put_line( x.data );
end loop;
END;
/891794 wrote:
Thank you all , see I am new to this database field , I am not a pro.Not a problem. However, one of the very first things you should learn is that dynamic SQL is seldom needed and invariably just plain wrong.
If a table name is dynamic, or a column name is dynamic - then chances are excellent that your data model is already fubar'ed (or malema'ed to put it in a za.org perspective).
And even when you are in the very exceptional situation where dynamic SQL is needed, SQL injection is a MAJOR security concern.. and almost always ignored by implementing shoddy code to create and execute the dynamic SQL. -
How to filter particular xml tag value using -DBMS_XMLGEN / DBMS_XMLSTORE
Hi,
I am using dbms_xmlgen and dbms_xmlstore package to extract xml datafile tag value from file server to oracle database table.
I have used the below pl/sql program to extract the xml tag values to oracle relational table.Its working fine for me.
But I would like to extract the values based on particular filter condition.
The following xml program I have 3 rows I would like extract the xml data based on the following condition .
Filter condition
==============
the tag <STATE_ABBREVIATION> value shuold be 'CA' and the <CITY> tag value should be Palo_Alto then I will store the ZIPCODE
ZIP_CODE_EXTN,STATE_ABBREVIATION tag values in the Oracle Relational table.
The below pl/sql program storing all the three rows but I required the values based on the filter condition that I mentioned earlier.
Kindly assist me what are the steps that I need to change in this program.?
XML Program file content.
======================
<ZIPCODES>
<mappings>
<STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
<ZIPCODE>94301</ZIPCODE>
<ZIP_CODE_EXTN>9277</ZIP_CODE_EXTN>
<CITY>Palo_Alto</CITY>
</mappings>
<mappings>
<STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
<ZIPCODE>95302</ZIPCODE>
<ZIP_CODE_EXTN>9279</ZIP_CODE_EXTN>
<CITY>LA</CITY>
</mappings>
<mappings>
<STATE_ABBREVIATION>TX</STATE_ABBREVIATION>
<ZIPCODE>75038</ZIPCODE>
<ZIP_CODE_EXTN>7837</ZIP_CODE_EXTN>
<CITY>DALLAS</CITY>
</mappings>
</ZIPCODES>
PL/SQL Program for XML extract.
==========
declare
charString varchar2(80);
finalStr varchar2(4000) := null;
rowsp number;
insCtx DBMS_XMLStore.ctxType;
ctx dbms_xmlgen.ctxHandle;
v_FileHandle UTL_FILE.FILE_TYPE;
begin
v_FileHandle := utl_file.fopen('XMLTEST','XML_NEW_CITIES.XML','r') ;
loop
BEGIN
utl_file.get_line(v_FileHandle, charString);
exception
when no_data_found then
utl_file.fclose(v_FileHandle);
exit;
END;
dbms_output.put_line(charString);
if finalStr is not null then
finalStr := finalStr || charString;
else
finalStr := charString;
end if;
end loop;
insCtx := DBMS_XMLStore.newContext('SYS.ZIPCODES');
dbms_xmlgen.setRowsetTag(insCtx,'ZIPCODES');
dbms_xmlgen.setRowsetTag(insCtx,'mappings');
DBMS_XMLStore.clearUpdateColumnList(insCtx);
DBMS_XMLStore.setUpdateColumn(insCtx,'ZIPCODE');
DBMS_XMLStore.setUpdateColumn(insCtx,'ZIP_CODE_EXT N');
DBMS_XMLStore.setUpdateColumn(insCtx,'STATE_ABBREV IATION');
rowsp := dbms_xmlstore.insertXML(insCtx,finalstr);
end;
Thanks,
natThanks for your reply. :)
Its working fine in the DBMS_XMLSTORE package. Here I have given the code
CREATE OR REPLACE TYPE typ_dummy AS OBJECT
( "@ENO" NUMBER,
"@ENAME" VARCHAR2(100),
eno NUMBER,
ename VARCHAR2(100));
CREATE TABLE EMP
empno VARCHAR2(25),
sal NUMBER,
hiredate DATE,
typ TYP_DUMMY
DECLARE
insCtx DBMS_XMLStore.ctxType;
rows NUMBER;
xmldoc CLOB :=
'<ROWSET>
<ROW num="1">
<SAL>1800</SAL>
<EMPNO>739</EMPNO>
<HIREDATE>27-AUG-1996</HIREDATE>
<TYP ENO="739" ENAME="Nazurullah">
<ENO> 1 </ENO>
<ENAME> ALDRIN </ENAME>
</TYP>
</ROW>
<ROW>
<SAL>18000</SAL>
<EMPNO>7369</EMPNO>
<HIREDATE>27-AUG-1996</HIREDATE>
<TYP ENO="7369" ENAME="PEPPIN" />
</ROW>
<ROW>
<SAL>37000</SAL>
<EMPNO>20701</EMPNO>
<HIREDATE>27-AUG-1996</HIREDATE>
<TYP>
<ENO> 20701 </ENO>
<ENAME> VENKATACHALAM </ENAME>
</TYP>
</ROW>
</ROWSET>';
BEGIN
insCtx := DBMS_XMLStore.newContext('emp'); -- get saved context
-- Now insert the doc.
-- This will only insert into EMPNO, SAL and HIREDATE columns
rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
-- Close the context
DBMS_XMLStore.closeContext(insCtx);
END;
SELECT * FROM emp;
EMPNO SAL HIREDATE TYP(@ENO, @ENAME, ENO, ENAME)
739 1800 27-AUG-96 TYP_DUMMY(739, 'Nazurullah', 1, ' ALDRIN ')
7369 18000 27-AUG-96 TYP_DUMMY(7369, 'PEPPIN', NULL, NULL)
20701 37000 27-AUG-96 TYP_DUMMY(NULL, NULL, 20701, ' VENKATACHALAM ') -
Setting Two Row Tags issue using DBMS_XMLGEN.setrowtag ?
Hi All,
Am generating a xml using DBMS_XMLGEN.
I want to generate a XML in the following format
<MAIN>
<PACK = 1>
<EMP DETAILS>
Some data goes here
<EMP DETAILS>
<PACK = 2>
<EMP DETAILS>
Some data goes here
<EMP DETAILS>
Some data goes here
<EMP DETAILS>
Some data goes here
<PACK = 3>
<EMP DETAILS>
Some data goes here
<EMP DETAILS>
Some data goes here
<EMP DETAILS>
<MAIN>
Am able to set the only the following
DBMS_XMLGEN.setrowsettag('xmlhandle','MAIN');
DBMS_XMLGEN.setrowtag('xmlhandle','EMP DETAILS');
But the problem is setting another row tag <PACK>
Is it possible to set another rowtag ?
Please any inputs on this will be really helpful?I don't think you can set two different row tags in dbms_xmlgen. I'm also not sure about the "= 1", "= 2", etc. strings in your PACK tags. Perhaps I'm missing something but that doesn't look like legal XML.
Here's an approach that may help anyway though ...
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
set echo on
set long 10000
set longchunksize 10000
set pagesize 100
create or replace type emp_details as object
( empno integer, ename varchar2(10) )
Type created.
create or replace function getxmldata return clob
is
mysql dbms_xmlgen.ctxHandle ;
v_result clob ;
begin
mysql :=
dbms_xmlgen.newContext
'select emp_details( empno, ename ) as emp_details
from emp where deptno = 10'
dbms_xmlgen.setrowsettag(mysql,'MAIN');
dbms_xmlgen.setrowtag(mysql,'PACK');
v_result := dbms_xmlgen.getXML(mysql) ;
dbms_xmlgen.closeContext( mysql );
return( v_result );
end;
Function created.
show errors
No errors.
select getxmldata from dual ;
GETXMLDATA
<?xml version="1.0"?>
<MAIN>
<PACK>
<EMP_DETAILS>
<EMPNO>7782</EMPNO>
<ENAME>CLARK</ENAME>
</EMP_DETAILS>
</PACK>
<PACK>
<EMP_DETAILS>
<EMPNO>7839</EMPNO>
<ENAME>KING</ENAME>
</EMP_DETAILS>
</PACK>
<PACK>
<EMP_DETAILS>
<EMPNO>7934</EMPNO>
<ENAME>MILLER</ENAME>
</EMP_DETAILS>
</PACK>
</MAIN>
1 row selected.
drop function getxmldata ;
Function dropped.
drop type emp_details ;
Type dropped.--
Joe Fuda
SQL Snippets -
Qyery returning empty result using dbms_xmlgen doesn't work as expected
Hi group.
I'm using the following code in a PSQL procedure
procedure selectXML(consulta in varchar2,xmlout out clob) as
context dbms_xmlquery.ctxtype;
resultado clob;
tam integer;
context_gen dbms_xmlgen.ctxHandle;
begin
IF useDBMS_XMLGEN THEN
BEGIN
context_gen:=DBMS_XMLgen.newContext(consulta);
DBMS_XMLgen.usenullattributeindicator(context_gen,true);
resultado:=DBMS_XMLgen.getxml(context_gen);
tam:=dbms_lob.getlength(resultado);
dbms_lob.copy(xmlout,resultado,tam,1,1);
DBMS_XMLgen.closecontext(context_gen);
ELSE
context:=DBMS_XMLQUERY.newContext(consulta);
DBMS_XMLQUERY.usenullattributeindicator(context,true);
resultado:=DBMS_XMLQUERY.getxml(context);
tam:=dbms_lob.getlength(resultado);
dbms_lob.copy(xmlout,resultado,tam,1,1);
DBMS_XMLQUERY.closecontext(context);
END IF;
end;
If the query used returns nothing (for example 'SELECT * FROM dual WHERE rownum=0') using the DBMS_XMLQUERY code, the function getxml() returns
<?xml version = '1.0'?>
<ROWSET/>
but using the DBMS_XMLGEN code, the function getxml() returns nothing.
Is that behaviour normal or am I doing anything wrong?
I'm testing the code in Oracle9i Enterprise Edition Release 9.2.0.7.0 but it must also be run Oracle 8 and 10
Thanks in advance
JavierIs that behaviour normal or am I doing anything wrong?That seems to be normal behaviour per design:
SQL> select 1 id, dbms_xmlgen.getxml('select * from dual where 1=0') xml from dual
union all
select 2, dbms_xmlquery.getxml('select * from dual where 1=0',0) xml from dual
union all
select 3, dbms_xmlquery.getxml('select * from dual where 1=0',1) xml from dual
union all
select 4, dbms_xmlquery.getxml('select * from dual where 1=0',2) xml from dual
ID XML
1
2 <?xml version = '1.0'?>
<ROWSET/>
3 <?xml version = '1.0'?>
<!DOCTYPE ROWSET [
<!ELEMENT ROWSET (ROW)*>
<!ELEMENT ROW (DUMMY)>
<!ATTLIST ROW num CDATA #REQUIRED>
<!ELEMENT DUMMY (#PCDATA)>
]>
<ROWSET/>
4 <?xml version = '1.0'?>
<DOCUMENT xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:element name="ROWSET">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ROW" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="DUMMY" type="xsd:string" nullable="true" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="num" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<ROWSET xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#
/DOCUMENT/xsd:schema[not(@targetNamespace)]"/>
</DOCUMENT>
4 rows selected. -
Creating XML using DBMS_XMLGEN with a namespace
Is it possible to create an XMLTYPE using the DBMS_XMLGEN function set that contains a namespace. As far as I can see only the 'setrowsettag' function allows any control over what goes into the root element - should I be including, for example, an attribute called 'xmlns' with a value?
The reason I ask all this is I'm trying to validate xml created from a select statement against a registered xsd.
The xsd I've registered:
<?xml version="1.0" encoding="WINDOWS-1252"?>
<xs:schema targetNamespace="http://www.sepa.org/2007/XMLSchemas/Site" xmlns:sit="http://www.sepa.org/2007/XMLSchemas/Site" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sepa.org/2007/XMLSchemas/Site Site.xsd" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:flags="311" oraxdb:schemaURL="http://www.sepa.org/2007/XMLSchemas/Site.xsd" oraxdb:schemaOwner="XMLDBMASTER" oraxdb:numProps="14">
<xs:element name="site" oraxdb:propNumber="5953" oraxdb:global="true" oraxdb:SQLName="site" oraxdb:SQLType="site1681_T" oraxdb:SQLSchema="XMLDBMASTER" oraxdb:memType="258" oraxdb:defaultTable="site1683_TAB" oraxdb:defaultTableSchema="XMLDBMASTER">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType oraxdb:SQLType="site1681_T" oraxdb:SQLSchema="XMLDBMASTER">
<xs:sequence>
<xs:element name="SiteIDType" type="xs:ID" oraxdb:propNumber="5940" oraxdb:global="false" oraxdb:SQLName="SiteIDType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="SiteNameType" type="xs:string" minOccurs="1" oraxdb:propNumber="5941" oraxdb:global="false" oraxdb:SQLName="SiteNameType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="SiteAddressStructure" oraxdb:propNumber="5947" oraxdb:global="false" oraxdb:SQLName="SiteAddressStructure" oraxdb:SQLType="SiteAddressStructure1682_T" oraxdb:SQLSchema="XMLDBMASTER" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false">
<xs:complexType oraxdb:SQLType="SiteAddressStructure1682_T" oraxdb:SQLSchema="XMLDBMASTER">
<xs:sequence>
<xs:element name="AddressLine1" type="xs:string" minOccurs="1" oraxdb:propNumber="5942" oraxdb:global="false" oraxdb:SQLName="AddressLine1" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="AddressLine2" type="xs:string" minOccurs="0" oraxdb:propNumber="5943" oraxdb:global="false" oraxdb:SQLName="AddressLine2" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="AddressLine3" type="xs:string" minOccurs="0" oraxdb:propNumber="5944" oraxdb:global="false" oraxdb:SQLName="AddressLine3" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="AddressLine4" type="xs:string" minOccurs="1" oraxdb:propNumber="5945" oraxdb:global="false" oraxdb:SQLName="AddressLine4" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="PostCode" type="xs:string" minOccurs="0" oraxdb:propNumber="5946" oraxdb:global="false" oraxdb:SQLName="PostCode" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SiteTelephoneNoType" type="xs:string" minOccurs="0" oraxdb:propNumber="5948" oraxdb:global="false" oraxdb:SQLName="SiteTelephoneNoType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="SiteMobilePlantType" type="xs:string" minOccurs="0" oraxdb:propNumber="5949" oraxdb:global="false" oraxdb:SQLName="SiteMobilePlantType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="SiteFaxNoType" type="xs:string" minOccurs="0" oraxdb:propNumber="5950" oraxdb:global="false" oraxdb:SQLName="SiteFaxNoType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<!--***Location code must reference the code in the Location Dataset***-->
<xs:element name="SiteLocationCode" type="xs:string" minOccurs="1" oraxdb:propNumber="5951" oraxdb:global="false" oraxdb:SQLName="SiteLocationCode" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="SitePopulationEquivType" type="xs:positiveInteger" minOccurs="0" oraxdb:propNumber="5952" oraxdb:global="false" oraxdb:SQLName="SitePopulationEquivType" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The method for generating the XML:
DECLARE
v_ctx DBMS_XMLGEN.ctxhandle;
v_xml XMLTYPE;
BEGIN
v_ctx:=DBMS_XMLGEN.newcontext
SELECT e.site_id "SiteIDType", e.site_name "SiteNameType", sit_address(e.addr_line1, e.addr_line2,
e.addr_line3, e.addr_line4, e.post_code) AS "SiteAddressStructure", e.tel_no "SiteTelephoneNoType"
, e.mobile_plant "SiteMobilePlantType",
e.fax_no "SiteFaxNoType", e.ge1_location_code "SiteLocationCodeType" ,e.population_equivalent "SitePopulationEquivType"
FROM EL03_SITES e
WHERE e.site_id = 15'
DBMS_XMLGEN.setrowsettag (v_ctx, 'site');
DBMS_XMLGEN.setrowtag (v_ctx, NULL);
v_xml := DBMS_XMLGEN.getxmltype (v_ctx);
INSERT INTO js_xml_test
(ID, xml_data
VALUES ('site test', v_xml
COMMIT;
DBMS_XMLGEN.closecontext (v_ctx);
END;
The resulting XML:
<site>
<SiteIDType>15</SiteIDType>
<SiteNameType>Finlas Water Treatment Works</SiteNameType>
<SiteAddressStructure>
<AddressLine1>Finlas Water Treatment Works</AddressLine1>
<AddressLine2>Shermor Farm</AddressLine2>
<AddressLine3>Luss</AddressLine3>
<AddressLine4>Alexandria</AddressLine4>
<PostCode>G83 8RH</PostCode>
</SiteAddressStructure>
<SiteTelephoneNoType>01389 850224</SiteTelephoneNoType>
<SiteMobilePlantType>N</SiteMobilePlantType>
<SiteLocationCodeType>123428</SiteLocationCodeType>
</site>
When I try to validate it, I get:
ORA-30937: No schema definition for 'site' (namespace '') in parent '/'
ORA-06512: at "SYS.XMLTYPE", line 345
ORA-06512: at line 30
How do I get a namespace declaration in the XML? Any suggestions gratefully received.Did you change any of the text in the lob write statements ?
I believe you get this error if you increase the number of characters without increasing the 1st argument which looks as though it represents the number of characters -
How to change the default element tag using dbms_xmlgen
here is my code that generate output for purchase order data. I followed the syntax shown in xml db developer guide.
I am getting the results but element tags are CAPS letters( As the coloumn names in the type defenitions are stored in CAPS in Oracle). but I need to show in small letters as per my requirement.
can anyone help me how to change the default tag names for elements.
==================================HERE IS THE CODE==================
DECLARE
qryCtx DBMS_XMLGEN.ctxHandle;
result CLOB;
BEGIN
qryCtx := DBMS_XMLGEN.newContext
('SELECT PODL_H_T
( CLOSEDDATETIME ,
COMPANY ,
CAST(MULTISET
(SELECT LINENUMBER ,
COMPANY ,
PURCHASEORDERID ,
ITEM ,
QUANTITYUM ,
TOTALQUANTITY
FROM cpo_wms_podl_LINES
WHERE PURCHASEORDERID = PH.PURCHASEORDERID) as PurchaseOrderDetailList
FROM cpo_wms_podl_HEADERS PH ');
-- now get the result
DBMS_XMLGEN.setRowSetTag(qryCtx, 'Receipts' );
DBMS_XMLGEN.setRowTag(qryCtx, 'PurchaseOrder' );
result := DBMS_XMLGEN.getXML(qryCtx);
INSERT INTO temp_clob_tab VALUES (result);
DBMS_XMLGEN.closeContext(qryCtx);
END;
-- select * from temp_clob_tab
===========create type script=====================
cpo_wms_podl_HEADERS
CREATE or replace TYPE PurchaseOrderDetail AS OBJECT(
LINENUMBER VARCHAR2(400 BYTE),
COMPANY VARCHAR2(400 BYTE),
PURCHASEORDERID VARCHAR2(400 BYTE),
ITEM VARCHAR2(400 BYTE),
QUANTITYUM VARCHAR2(400 BYTE),
TOTALQUANTITY NUMBER
create type PurchaseOrderDetailList as table of PurchaseOrderDetail
create table temp_clob_tab(result CLOB)
create type podl_HEADERS_list_t as table of podl_HEADERS_t
CREATE or replace TYPE PODL_H_T AS OBJECT
CLOSEDDATETIME DATE,
COMPANY VARCHAR2(400 BYTE),
CREATEDDATETIME DATE,
PURCHASEORDERID VARCHAR2(400 BYTE),
SHIP_TO VARCHAR2(400 BYTE),
linelist PurchaseOrderDetailList
)but I need to show in small letters as per my requirement.add alias column names in double quotes as in
SQL> select dbms_xmlgen.getxmltype('select dname "DeptName", loc "Location" from dept') dept_xml from dual
DEPT_XML
<ROWSET>
<ROW>
<DeptName>ACCOUNTING</DeptName>
<Location>NEW YORK</Location>
</ROW>
<ROW>
<DeptName>RESEARCH</DeptName>
<Location>DALLAS</Location>
</ROW>
<ROW>
<DeptName>SALES</DeptName>
<Location>CHICAGO</Location>
</ROW>
<ROW>
<DeptName>OPERATIONS</DeptName>
<Location>BOSTON</Location>
</ROW>
<ROW>
<DeptName>SALES</DeptName>
<Location>MUNICH</Location>
</ROW>
</ROWSET>
1 row selected. -
XML publisher report using dbms_xmlgen (ORA-06502)
Dear All,
I have written the below code to generate xml output in Oracle Apps. The code is working fine for less records. But when CLOB size is more than 32k, then
it giving the ORA-06502 error as fnd_file.put_line(fnd_file.output,v_result) can only write 32k at a time.
Can anyone let me know how to handle this? Any help on this would be highly appreciated.
PROCEDURE MAIN ( errbuf OUT VARCHAR2
,retcode OUT NUMBER
) IS
TYPE g_query_ref IS REF CURSOR;
v_query_ref g_query_ref;
v_handle dbms_xmlgen.ctxhandle;
v_result clob;
BEGIN
OPEN v_query_ref FOR
SELECT invoice_num,
description,
customer_no,
customer_name
FROM XX_INVOICE_DETAILS;
v_handle := dbms_xmlgen.newContext(v_query_ref);
DBMS_XMLGEN.SETROWTAG (v_handle , 'INVOICE');
v_result := dbms_xmlgen.getXML(v_handle);
fnd_file.put_line(fnd_file.output,v_result);
EXCEPTION
when others then
errbuf := sqlerrm;
retcode := sqlcode;
fnd_file.put_line(fnd_file.log,’sqlerrm ‘||sqlerrm);
END MAIN;
Thanks in Advance.
Regards,
AstikWhat you need to do is to chop your CLOB up into smaller strings, something like:
l_size := DBMS_LOB.getlength (l_clob);
IF (NVL (l_size, 0) = 0) THEN
raise_application_error (-20001, 'CLOB is NULL');
END IF;
l_offset := 1;
-- Loop
WHILE (l_offset <= l_size) LOOP
l_char := DBMS_LOB.SUBSTR (l_clob,1,l_offset);
IF (l_char = CHR (10)) THEN
FND_FILE.NEW_LINE(FND_FILE.output, 1);
ELSE
FND_FILE.PUT(FND_FILE.output, l_char);
END IF;
-- Increment Offset.
l_offset:= l_offset+1;
END LOOP;
FND_FILE.NEW_LINE(fnd_file.output, 1); -
Generate XML output using DBMS_XMLGEN.getxmltype and not from rdf
Hi,
I have a requirement to display output from a particular table in XL format. Out of all the known possible options, I am planning to use the XML publisher to generate XL output.
For the data source, instead of using the conventional way of creating XML data using rdf,I am planning to use DBMS_XMLGEN.getxmltype pl/sql procedure to generate the XML output. And from the output, call the template to generate the required Excel output.
Now, I am using the following code to generate XML output but am not sure how to proceed from here. I need to first print the XML data in the FND Output file after which I was planning to call the 'XML Report Publisher' (XDOREPPB) program and use the current request id to get the excel output but I am not able to find the way to print the XML data in the output file as:
fnd_file.put_line (fnd_file.output, l_xml_type); - is throwing an error as l_xml_type is an XML data output.
PROCEDURE xml_main (
errbuf OUT VARCHAR2
,retcode OUT VARCHAR2
,p_project_from IN VARCHAR2
,p_project_to IN VARCHAR2
AS
l_xml_type XMLTYPE;
BEGIN
SELECT DBMS_XMLGEN.getxmltype
('SELECT fnd_global.conc_request_id
,TO_CHAR (segment1)
,to_char(start_date,''MM/DD/RRRR'')
,to_char(xxmcc_project_details_pkg.current_profit_projection
(project_id),''999,999,990.90'')
,to_char(xxmcc_project_details_pkg.cost_to_date (project_id),''999,999,990.90'')
,''1''
FROM pa_projects_all
WHERE segment1 BETWEEN NVL (p_project_from, segment1)
AND NVL (p_project_to, segment1)')
INTO l_xml_type
FROM DUAL;
fnd_file.put_line (fnd_file.output, l_xml_type);
END xml_main;
Can anyone point me as to how to publish XML output using a PL/SQL procedure (DBMS_XMLGEN.getxmltype)
Thanks.Pl see if the example included in this presentation helps http://www.oracle.com/technology/products/applications/Events/OOW-2006/EBS/S281401_Sridhar_Bogelli.pdf
Also, you do not need to explicitly call XDOREPPB in later versions of XML Publisher. If you set up everything correctly (as described in the presentation above and the link below) the Output Post Processor is called automatically after the XML file is generated successfully.
Another excellent tutorial is at http://www.oracle.com/technology/obe/fusion_middleware/fusion/bi/xmlp_ebiz/index.html
HTH
Srini -
Add xmlns tag to Xml file using DBMS_XMLGEN
I am using Oracle Release 10.1.0.4.2 version .
I want to create a xml file according to some data available in the relational database tables. For the same i created object types and then view with the object types since data is scattered in many tables.
Then i used DBMS_XMLGEN.getxml to generate the xml with query from the object view.
Is there an option to add xmlns attribute to the generated xml file.
Please let me know if any additional details are needed.If you want to add the namespace declaration in the root element, I don't think it's possible with DBMS_XMLGEN directly.
You can instruct DBMS_XMLGEN to treat some object fields as XML attributes by prefixing them with "@" (e.g. "@my_attribute") but you cannot control that for enclosing elements.
A possible solution is to add it afterwards using XSLT, or insertChildXML, but apparently the latter is not available in your version.
However...
For the same i created object types and then view with the object types since data is scattered in many tables.Since the data comes from different tables, why not use SQL and SQL/XML functions to build the document?
It's straightforward, simple, and doesn't need additional objects.
select xmlelement("Departments",
xmlattributes('http://xmlns.example.org' as "xmlns")
, xmlagg(
xmlelement("Department",
xmlattributes(d.deptno as "Id")
, xmlelement("Name", d.dname)
, xmlelement("Employees"
, xmlagg(
xmlelement("Employee",
xmlattributes(e.empno as "Id")
, xmlforest(
e.ename as "Name"
, e.job as "Job"
) order by e.empno
) order by d.deptno
from scott.dept d
join scott.emp e on e.deptno = d.deptno
group by d.deptno, d.dname
;Output :
<Departments xmlns="http://xmlns.example.org">
<Department Id="10">
<Name>ACCOUNTING</Name>
<Employees>
<Employee Id="7782">
<Name>CLARK</Name>
<Job>MANAGER</Job>
</Employee>
<Employee Id="7839">
<Name>KING</Name>
<Job>PRESIDENT</Job>
</Employee>
<Employee Id="7934">
<Name>MILLER</Name>
<Job>CLERK</Job>
</Employee>
</Employees>
</Department>
<Department Id="20">
<Name>RESEARCH</Name>
<Employees>
<Employee Id="7369">
<Name>SMITH</Name>
<Job>CLERK</Job>
</Employee>
<Employee Id="7566">
<Name>JONES</Name>
<Job>MANAGER</Job>
</Employee>
<Employee Id="7902">
<Name>FORD</Name>
<Job>ANALYST</Job>
</Employee>
</Employees>
</Department>
<Department Id="30">
<Name>SALES</Name>
<Employees>
<Employee Id="7499">
<Name>ALLEN</Name>
<Job>SALESMAN</Job>
</Employee>
<Employee Id="7521">
<Name>WARD</Name>
<Job>SALESMAN</Job>
</Employee>
<Employee Id="7654">
<Name>MARTIN</Name>
<Job>SALESMAN</Job>
</Employee>
<Employee Id="7698">
<Name>BLAKE</Name>
<Job>MANAGER</Job>
</Employee>
<Employee Id="7844">
<Name>TURNER</Name>
<Job>SALESMAN</Job>
</Employee>
<Employee Id="7900">
<Name>JAMES</Name>
<Job>CLERK</Job>
</Employee>
</Employees>
</Department>
</Departments> -
Does BI Publisher use DBMS_XMLGEN?
Hi Tim/Klaus.
Does BI Publisher use DBMS_XMLGEN to extract the data from oracle datasources or do you just get JDBC result sets and wrap them in <ROWSET> tags?
Dave1>Close all microsoft office suite products.
2>Find MSComctlLib.exd inside "C:\Documents and Settings\<YOUR USER NAME>\Application Data\Microsoft\forms
3>rename to MSComctlLib.exd_bak
4> Done :) -
Data to xml file DECLARE Ctx DBMS_XMLGEN.ctxHandle;
Hi all,
I want to export the table data to xml file.
I typed:
SQL> set serveroutput on
SQL> DECLARE
2 Ctx DBMS_XMLGEN.ctxHandle;
3 xml clob;
4 emp_no NUMBER := 7369;
5
6 xmlc varchar2(4000);
7 off integer := 1;
8 len integer := 4000;
9 BEGIN
10 Ctx := DBMS_XMLGEN.newContext('SELECT * FROM emp WHERE empno ='||emp_no);
11 DBMS_XMLGen.setRowsetTag(Ctx, 'EMP_TABLE');
12 DBMS_XMLGen.setRowTag(Ctx, 'EMP_ROW');
13 DBMS_XMLGEN.closeContext(Ctx);
14 xml := DBMS_XMLGEN.getXML(Ctx);
15
16 DBMS_LOB.READ(xml, len, off, xmlc);
17 DBMS_OUTPUT.PUT_LINE(xmlc);
18 END;
19 /
And I got
DECLARE
ERROR at line 1:
ORA-19019: Invalid context passed to DBMS_XMLGEN.GETXML
ORA-06512: at "SYS.DBMS_XMLGEN", line 7
ORA-06512: at "SYS.DBMS_XMLGEN", line 147
ORA-06512: at line 14
Any suggestions will be appreciated.
Thank you
aalexsunYou've closed the context, before evening calling getXML
13 DBMS_XMLGEN.closeContext(Ctx);
14 xml := DBMS_XMLGEN.getXML(Ctx); -
Authentication problem - solved, but maybe a bug in Mac OS X?
Hi,
I've a rather small installation with only a handful of users configured on a Mac mini (Mac OS X Server, 10.6.8). All of them use the mail, calendar and addressbook server on the Mac, nothing more. They use it with Mac, iPhone and iPad. Everything worked fine for months but suddenly all of them were faced authentication problems: it was not possible to login on the imap server, the calendar server, the addressbook server. It was possible to login using the admin account on the server directly. Moreover, all users disappeared from the workgroup manager, however they still were available on the servers LDAP server and findable using ldapsearch.
First, I used to completely restart the server to solve the problem, but it reappeared after only few hours again.
Second, after understanding more about the authentication process, I found the "killall DirectoryService" was sufficient to solve the problem, but it still reappeared after few hours.
Then I found the, once the problem occured, there was nearly no more communication to the local LDAP server on port 389 on localhost. When everything was working fine, the was a lot of such communication, including queries for usernames, when a login attempt was made. I started a "tcpdump -n -i lo0 port 389" and waited for the problem again. After the problem occured, I found in the pcap files that there were a few final query attempts, actually attempts the open a port 389 TCP connection to the slapd running on localhost, which were answered with a TCP RST. Then, no more attempts were made until l restarted the DirectoryService. Using the logfile of the slapd I found that this happened exactly at the time the slapd was stopped and restarted. And - surprisingly for me - stopping and restarting the slapd happened exactly once an hour.
I then found that it happened exactly at the time the time machine backup process was started and indeed it was possible to trigger the event of restarting the slapd by manually starting a time machine backup.
(Indeed, I switched my backup strategy from SuperDuper to time machine the other day and maybe that was the time the problem occured for the first time. I know that time machine is not considered as the best backup strategy for a server but I wanted to try on my own.)
Google helped my to find a hint that time machine will actually stop and restart slapd - which is a generally a good idea, since otherwise a backup from some open database files would be made, which could work but may fail. So, I thing, someone of the developers thought about that problem too and has considered time machine for backups of a server.
However, a not running slapd can not answer queries from a DirectoryService and a stopping or starting process might indeed end up with TCP SYNs answered with TCP RST.
My solution was to disable time machine again and from that time the problem does not occur again.
I'm wondering why the DirectoryService process isn't starting to query the slapd again after a failed connection. Isn't this a bug? After this experience I consider time machine as not only the not preferred backup solution for a server but as completely incompatible with Mac OS X server - although, as I said, it seems that someone thought about backing up the LDAP database using time machine.
(On a Lion server this problem does not occur, the slapd will not be stopped and restarted when time machine is running. Moreover, I saw a com.apple.slapd.start notification in the slapd.log ... maybe this tells DirectoryService to try again.)
Cheers,
WolfgangAnother problem I found with the MacOS X key bindings: the 6 key doesn't work!
In the config that ships with SQL Developer, I found this:
<Item class="oracle.javatools.util.Pair">
<first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
<second class="oracle.ide.keyboard.KeyStrokes">
<data>
<Item class="javax.swing.KeyStroke">6</Item>
</data>
</second>
</Item>
which should be:
<Item class="oracle.javatools.util.Pair">
<first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
<second class="oracle.ide.keyboard.KeyStrokes">
<data>
<Item class="javax.swing.KeyStroke">meta 6</Item>
</data>
</second>
</Item>
Maybe you are looking for
-
HT5517 how can I watch from my computer to apple tv
how can i watch my tv shows fro my mac air to apple tv
-
Can't change the color of text of links on my Welcome Page
I have a Welcome page with four links that happen to be text that I dragged over from my list of sites. I can change the text style and size but I cannot change the color from the default reddish brown.
-
Filter plugin. Problem after change image depth.
Hi All ! I already wrote filter plugin it work fine but only for image depth 8bit, after i change image depth on 16 or 32 bits I getting error msg box from photoshop. I try change on 'destination.colBits = 8' or 'destination.colBits = pChannel->depth
-
Weblogic.system.listenPort property in Weblogic 6.0?
There is any property for manually indicate listen port like: weblogic.system.listenPort Baco, por siempre loado, os libre del cirrotico mal y del advenimiento gonococico. [att1.html]
-
Exporting pdf from cs6 results in much lower resolution file
Hi, I try to export various files photos,posters at jpeg and psd formats to pdf but I'm getting much lower resolution files eg from 2480x3508jpeg to 500x800 pdf. The same happens to all cs6 design standard suite. To the preview as well. I'm using mav