Oracle XML functions return tags for null columns.
I am currently writing a SOAP Message base on a SQL statement formatted as XML. However, I am having problems with Oracle XML functions not returning tags for null columns as seen in my example below. Is the a way to get Oracle XML functions to return empty tags for null column?
CREATE TABLE FOREXAMPLE_TABLE (COLUMN_1 VARCHAR2 (4000),
COLUMN_2 VARCHAR2 (4000),
COLUMN_3 VARCHAR2 (4000));
INSERT INTO FOREXAMPLE_TABLE (COLUMN_2)
VALUES ('This column is not null');
COMMIT;
SELECT XMLELEMENT ( "soap:Envelope",
XMLATTRIBUTES ( 'http://schemas.xmlsoap.org/soap/envelope/' AS "xmlns:soap"),
XMLELEMENT ( "soap:Body",
XMLATTRIBUTES ( 'http://Custom_Column/types/' AS "xmlns:ns1"),
XMLELEMENT ( "ns1:New_Instance",
XMLELEMENT ( "ns1:Input_XMLDoc",
XMLFOREST(fe.COLUMN_1 as "Column_1",
fe.COLUMN_2 as "Column_2",
fe.COLUMN_3 as "Column_3"))))) as xml
FROM FOREXAMPLE_TABLE fe
The results returned from the select statement.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://Custom_Column/types/"><ns1:New_Instance>
<ns1:Input_XMLDoc><Column_2>This column is not null</Column_2>
</ns1:Input_XMLDoc></ns1:New_Instance></soap:Body></soap:Envelope>
The desired results for the select statement.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://Custom_Column/types/"><ns1:New_Instance>
<ns1:Input_XMLDoc><Column_1></Column_1>
<Column_2>This column is not null</Column_2><Column_3></Column_3>
</ns1:Input_XMLDoc></ns1:New_Instance></soap:Body></soap:Envelope>
jeeman
An alternative may be be to use xmlconcat instead of xmlforest:
Time Start: 30.06.2007 18:52:41
PL/SQL procedure successfully completed.
michaels> select xmlelement
("soap:Envelope",
xmlattributes
('http://schemas.xmlsoap.org/soap/envelope/' as "xmlns:soap"),
xmlelement
("soap:Body",
xmlattributes ('http://Custom_Column/types/' as "xmlns:ns1"),
xmlelement ("ns1:New_Instance",
xmlelement ("ns1:Input_XMLDoc",
xmlconcat (xmlelement("Column_1", fe.column_1),
xmlelement("Column_2", fe.column_2),
xmlelement("Column_3", fe.column_3)
).extract('.').getstringval() as xml
from (select null column_1, 'This column is not null' column_2,
null column_3
from dual) fe
XML
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://Custom_Column/types/">
<ns1:New_Instance>
<ns1:Input_XMLDoc>
<Column_1/>
<Column_2>This column is not null</Column_2>
<Column_3/>
</ns1:Input_XMLDoc>
</ns1:New_Instance>
</soap:Body>
</soap:Envelope>
Similar Messages
-
XMLGEN: Produce XML dump of a table WITH tags for null column values
I am new to generating XML so bear with me....
We have a customer who needs an XML extract of data, including tags for any column that is null.
I created a simple test case below using DBMS_XMLGEN.getXML. The first row (A1) has no null values and thus tags for columns A, BEE and CEE are produced. The second row (A2) has null in column BEE and thus tags for only columns A and CEE are produced.
Is there a way to force a tag for null column BEE in the second row?
create table foo (A varchar2(10), BEE number, CEE date);
insert into foo values ('A1',1,sysdate);
insert into foo values ('A2',null,sysdate);
SELECT DBMS_XMLGEN.getXML('SELECT * FROM foo') FROM dual;
<ROWSET>
<ROW>
<A>A1</A>
<BEE>1</BEE>
<CEE>27-SEP-12</CEE>
</ROW>
<ROW>
<A>A2</A>
<CEE>27-SEP-12</CEE>
</ROW>
</ROWSET>What's the database version? (SELECT * FROM v$version)
Could you use this instead :
SQL> select xmlserialize(document
2 xmlelement("ROWSET",
3 xmlagg(
4 xmlelement("ROW",
5 xmlelement("A", a)
6 , xmlelement("BEE", bee)
7 , xmlelement("CEE", cee)
8 )
9 )
10 )
11 -- for display purpose only :
12 as clob indent
13 )
14 from foo
15 ;
XMLSERIALIZE(DOCUMENTXMLELEMEN
<ROWSET>
<ROW>
<A>A1</A>
<BEE>1</BEE>
<CEE>2012-09-27</CEE>
</ROW>
<ROW>
<A>A2</A>
<BEE/>
<CEE>2012-09-27</CEE>
</ROW>
</ROWSET>
Or,
SQL> select xmlserialize(document
2 xmlquery(
3 '(#ora:view_on_null empty #)
4 {
5 <ROWSET>{fn:collection("oradb:/DEV/FOO")}</ROWSET>
6 }'
7 returning content
8 )
9 as clob indent
10 )
11 from dual;
XMLSERIALIZE(DOCUMENTXMLQUERY(
<ROWSET>
<ROW>
<A>A1</A>
<BEE>1</BEE>
<CEE>2012-09-27</CEE>
</ROW>
<ROW>
<A>A2</A>
<BEE/>
<CEE>2012-09-27</CEE>
</ROW>
</ROWSET>
(where "DEV" is my test schema)
If you want to stick with DBMS_XMLGEN, you're gonna have to use PL/SQL and setNullHandling procedure.
Edited by: odie_63 on 27 sept. 2012 17:14 -
Dbms_xmlgen empty tags for null
Hi, i would like to know if there is a way of dbms_xmlgen generate closed xml tags when the field as a null value.
What currently happens to me in my code, is that it doesn't write the tags for null fields, example:
Person
| Name | Age | PhoneNumber |
| Joao | 24 | |
this would generate
<persons>
<person>
<Name>
Joao
</Name>
<Age>
24
</Age>
</person>
</persons>
and i want to generate
<persons>
<person>
<Name>
Joao
</Name>
<Age>
24
</Age>
<PhoneNumber />
</person>
</persons>
Best Regards
João Lopes
Edited by: Joao Lopes on 8/Jul/2009 3:59Check
SQL> DECLARE
ctx INTEGER
:= dbms_xmlgen.newcontext (
'select ''Jao'' "Name", 24 "Age", null "PhoneNumber" from dual '
BEGIN
dbms_xmlgen.setnullhandling (ctx, dbms_xmlgen.empty_tag);
dbms_output.put_line (dbms_xmlgen.getxml (ctx));
dbms_xmlgen.closecontext (ctx);
END;
<?xml version="1.0"?>
<ROWSET>
<ROW>
<Name>Jao</Name>
<Age>24</Age>
<PhoneNumber/>
</ROW>
</ROWSET>
PL/SQL procedure successfully completed. -
Oracle Asset (Functional) Practice Questions for Interviews and Exam
https://www.createspace.com/3495382
http://www.amazon.com/Functional-Questions-Interviews-Certification-Examination/dp/1456311581/ref=sr_1_4?ie=UTF8&s=books&qid=1289178586&sr=8-4
List Price: $29.99
Add to Cart
Oracle Asset (Functional) Practice Questions for Interviews and Certification Examination (Release 11i and 12)
Functional Consultant
Authored by Erp Gold
This book contains 150 Oracle Asset Practice Questions for functional consultants. Very useful for interviews and certification examinations.
Publication Date:
Oct 26 2010
ISBN/EAN13:
1456311581 / 9781456311582
Page Count:
94
Binding Type:
US Trade Paper
Trim Size:
6" x 9"
Language:
English
Color:
Black and White
Related Categories:
Computers / GeneralReported as spam!
-
Oracle Asset (Functional) Practice Questions for Interviews and Certificati
https://www.createspace.com/3495382
List Price: $29.99
Add to Cart
Oracle Asset (Functional) Practice Questions for Interviews and Certification Examination (Release 11i and 12)
Functional Consultant
Authored by Erp Gold
This book contains 150 Oracle Asset Practice Questions for functional consultants. Very useful for interviews and certification examinations.
Publication Date:
Oct 26 2010
ISBN/EAN13:
1456311581 / 9781456311582
Page Count:
94
Binding Type:
US Trade Paper
Trim Size:
6" x 9"
Language:
English
Color:
Black and White
Related Categories:
Computers / GeneralReported as spam!
-
Oracle XML Gateway Message Designer for Oracle EBS R12.1.2
Goog Day to everyone!
I'm Looking for the tool "XML Gateway Message Designer". I have found in Metalink(Oracle Support) the note ID 557101.1, here explain how to get the message designer for Oracle Apps R12. It says that you have to download the patch 4066964. This patch install the Oracle Workflow Builder (2.6.3.0.1) and the Oracle XML Gateway Message Designer (2.6.3). This tools are supported to be used with Oracle Apps 11.5.10 and 12.0.X.
The release of Oracle Apps that I'm using is 12.1.2.
Questions:
- The version of the Message Designer that you get from patch 4066964 works for OraApps R12.1.2 ?
- The version of the Workflow Builder that you get from patch 4066964 works for OraApps R12.1.2 ?
- If the version of Message Designer doesn't work with OraApps R12.1.2, where can I find one that works with it?
Thanks for your advice.
LCJHi Hussein,
Thanks for replay.
I downloaded the rapid install package from e-delivery. The B53824-01_4of4 was the OWB installer, and it has a readme file that says: "+This patch contains Oracle Workflow Builder (version 2.6.3.0.1) and Oracle XML Gateway Message Designer (version 2.6.3). These client tools are supported for use with an Oracle E-Business Suite Release 12.1 instance.+"
I believe, as well as you, that it should be work for 12.1.2.
I'm gonna make some test, and in a few days I will post my results.
Thanks for the help.
LCJ -
Using '=' to check for NULL column value
We are currently encountering an issue where 10.1.0.5 is happily accepting a check on a column for a null value with what I have always known to be an invalid syntax.
For instance:
select col1 from my table where col1=null
Although this is wrong and we are working on locating the queries formatted as such, what I am wondering is why is it working on the 10.1.0.5 version but we cannot get the same query to execute on 8i, 9i, 10.2.0...? Is there a flag that can be enabled to allow this compare?I am familiar with the correct syntax to be using. What I am looking for is a possible explanation as to why the query below returns the correct results on 10.1.0.5 and returns nothing in all other versions. I would expect the same behavior across all instances. See the two lines in bold "AREA=NULL" and "SUBAREA=NULL"
SELECT DISTINCT
UNIQID,
MGRCOMMENT,
REQ.CREATED_BY CREATED,
C2.CNAME DEVELOPER,
C5.CNAME PRODMGR,
C3.CNAME ASSIGNED,
C4.CONTACTID CURRENTUSER,
ID,
STATUSNAME,
REQ.STATUS STATUSID,
PRIORITYNAME,
TITLE,
MAS1.MODULENAME,
MAS1.AREANAME,
MAS1.SUBAREANAME,
MIN1.MODULE,
MIN2.AREA,
MIN3.SUBAREA
FROM REQ,
PRIORITY,
STATUS,
(SELECT FIRST_VALUE(M1.MODULENAME)
OVER (PARTITION BY REQUNIQID ORDER BY MODULENAME ROWS UNBOUNDED PRECEDING) MODULENAME, FIRST_VALUE(A1.AREANAME)
OVER (PARTITION BY REQUNIQID ORDER BY AREA ROWS UNBOUNDED PRECEDING) AREANAME, FIRST_VALUE(SA1.SUBAREANAME)
OVER (PARTITION BY REQUNIQID ORDER BY SUBAREANAME ROWS UNBOUNDED PRECEDING) SUBAREANAME, REQUNIQID
FROM REQMOD, MOD M1, ARA A1, SBARA SA1
WHERE M1.MODULEID = REQMOD.MODULE
AND A1.AREAID = REQMOD.AREA
AND SA1.SUBAREAID = REQMOD.SUBAREA) MAS1,
(SELECT FIRST_VALUE(C2.CNAME) OVER (PARTITION BY REQUNIQID ORDER BY CNAME ROWS UNBOUNDED PRECEDING) CNAME, REQUNIQID
FROM REQ_ASSIGN, CONTACT C2
WHERE C2.CONTACTID = REQ_ASSIGN.CONTACTID
AND ASSIGNMENT_TYPE=2) C2,
(SELECT FIRST_VALUE(C5.CNAME) OVER (PARTITION BY REQUNIQID ORDER BY CNAME ROWS UNBOUNDED PRECEDING) CNAME, REQUNIQID
FROM REQ_ASSIGN, CONTACT C5
WHERE C5.CONTACTID = REQ_ASSIGN.CONTACTID
AND ASSIGNMENT_TYPE=1) C5,
(SELECT FIRST_VALUE(C3.CNAME)
OVER (PARTITION BY REQUNIQID ORDER BY CNAME ROWS UNBOUNDED PRECEDING) CNAME, REQUNIQID
FROM REQ_ASSIGN, CONTACT C3
WHERE C3.CONTACTID = REQ_ASSIGN.CONTACTID
AND ASSIGNMENT_TYPE<>2
AND ASSIGNMENT_TYPE<>1) C3,
(SELECT DISTINCT REQUNIQID, CONTACTID FROM REQ_ASSIGN WHERE CONTACTID=5) C4,
(SELECT DISTINCT REQUNIQID, MODULE FROM REQMOD WHERE MODULE=1) MIN1,
*(SELECT DISTINCT REQUNIQID, AREA FROM REQMOD WHERE AREA=NULL) MIN2,*
*(SELECT DISTINCT REQUNIQID, SUBAREA FROM REQMOD WHERE SUBAREA=NULL) MIN3,*
REQCOMMENTS
WHERE PRIORITY.PRIORITYID = REQ.PRIORITY
AND STATUS.STATUSID = REQ.STATUS
AND MAS1.REQUNIQID = REQ.UNIQID
AND C2.REQUNIQID = REQ.UNIQID
AND C5.REQUNIQID = REQ.UNIQID
AND C3.REQUNIQID = REQ.UNIQID
AND C4.REQUNIQID = REQ.UNIQID
AND MIN1.REQUNIQID = REQ.UNIQID
AND MIN2.REQUNIQID = REQ.UNIQID
AND MIN3.REQUNIQID = REQ.UNIQID
AND REQCOMMENTS.REQUNIQID = REQ.UNIQID
AND REQ.PROJECTID = 3; -
Db function returning three db number columns...
Hi ,
Is it possible a db function to return three number columns fetched from a table...??
If for example , there is a db function such as...:
function x
return number
is
begin
select number_col_1 , number_col_2 , number_col_3
into var1 , var2 , var3
from table_a
where <a_condition>;
return <the_three_columns_selected>;
end;
so as in a select statement should write:
select a , b , x from a_table
many thanks ,
SimonAlternatively you can return a SQL collection:
SQL> create or replace function x (empno integer)
2 return sys.dbms_debug_vc2coll
3 is
4 var1 emp.job%type;
5 var2 emp.sal%type;
6 var3 emp.deptno%type;
7 begin
8 select job, sal, deptno
9 into var1, var2, var3
10 from emp
11 where empno = x.empno;
12
13 return sys.dbms_debug_vc2coll (var1, var2, var3);
14 end;
15 /
Function created.
SQL>
SQL> select empno, ename, x(empno) x from emp
2 where empno in (7788,7900)
3 /
EMPNO ENAME X
7788 SCOTT DBMS_DEBUG_VC2COLL('ANALYST', '3000', '20')
7900 JAMES DBMS_DEBUG_VC2COLL('CLERK', '950', '30') -
Sql query tuning for null columns
Hi All
I have one query which runs on a table X.
This table X has one column COL1 with 10 million rows.
Out of 10million rows, 4Million rows are null.
Btree Index is availabe on this column. No other type of index feasible.
I suspect that these null rows are causing burden over my query and is slowing response.
Is there any way i can improve performance for that query?
Any help will be appreciated.
Sun10
Oracle10G 10.2.0.3.0
Thanks
aps
Edited by: aps on Apr 3, 2009 9:44 AMAps,
YOu can generated explan plan from sqlplus like this
sqlplus username/password
Note: And if user is not set with plustrace then use sqlplus '/as sysdba' and qualify your tables with schemaname.table_name
sql>set timi on;
sql> set lines 400;
sql> set autotrace traceonly;
sql>select a.account_no,a.read_no,a.inc_obj from billadjmaster a,masterdata b
where a.account_no=b.acc_no
and
b.item_type=22
and b.idate>'23-mar-2009'
order by a.account_no,a.read_no;Regards -
Parsing XML with html tags for style
I'm using flash to pull in XML data, but I want to use html
tags to be able to style the text. When I add any html, it treats
it as a sub-node and ignores the data. Also, line breaks in the xml
are being converted to double spaced paragraphs? The relevant code
is basically this:
if (element.nodeName.toUpperCase() == "TEXT")
{//add text to text array
ar_text[s]=element.firstChild.nodeValue;
textbox1.text = ar_text[0];try to use htmlText instead text... like this:
textbox1.htmlText = ar_text[0]
adam -
The message in the title keeps popping up and disappearing where the cursor is or was or randomly when reading threads on this forum. What is this annoyance and how do I get rid of it?
Using Windows XP.Try Google Chrome. Not sure if it works on XP but pretty sure it does.
This was discussed in the forums comments area. This has been seen before. Not positive if there was a fix. -
Generation of XML Tags for columns in Lexical parameter in select query
Hi,
I have lexical parameter in my select statement of my data model in the report.
How do i generate XML tags for these columns inside a Lexical Parameter?
Simple Example: I have data model query as follows:
SELECT msi.inventory_item_id
&LP_SELECT
FROM mtl_system_items_b
Here my lexical Parameter LP_SELECT is generated in before report trigger as follows in my report:
:LP_SELECT := 'msi.segment1,msi.description';
So, the question is how to generate XML Tags for columns in Lexical Parameter(as in the example above, i need XML tags for these columns - segment1 and description)
Thanks,
Ratantry this
Select &order data_show
from oe_order_headers_all
where order_number ='7889'
and setting :order:='order_number'; in after parameter form trigger.
Hope this helps
Hamid -
Oracle Asset (Functional) Practichttps:/e Questions for Interviews and Exam
https://www.createspace.com/3495382
http://www.amazon.com/Functional-Questions-Interviews-Certification-Examination/dp/1456311581/ref=sr_1_4?ie=UTF8&s=books&qid=1289178586&sr=8-4
List Price: $29.99
Add to Cart
Oracle Asset (Functional) Practice Questions for Interviews and Certification Examination (Release 11i and 12)
Functional Consultant
Authored by Erp Gold
This book contains 150 Oracle Asset Practice Questions for functional consultants. Very useful for interviews and certification examinations.
Publication Date:
Oct 26 2010
ISBN/EAN13:
1456311581 / 9781456311582
Page Count:
94
Binding Type:
US Trade Paper
Trim Size:
6" x 9"
Language:
English
Color:
Black and White
Related Categories:
Computers / GeneralReported as spam!
-
Setting up Oracle XML Gateway for EBS 12.1.3
Hi Experts,
We are currently working on R12.1.3 and was asked to check on how to setup/integrate XML Gateway on R12.1.3.
I have gone though many pages of this forums and checked the support ID's as given below :
Installing Oracle XML Gateway and Oracle Workflow with Oracle Applications 11i [ID 152775.1] --> Its for 11i, don't find the same for R12.
Oracle XML Gateway Release Notes, Release 12.1.3 --> does not help giving the information on how to setup XML Gateway
Found the below link but not sure if this is what was asked and looks like Client Desktop Installation.
11i - 12 How To Download and Install the Latest Oracle Workflow Builder (Client Tool) and XML Gateway Message Designer for E-Business (Doc ID 261028.1)
I don't know much about Oracle XML Gateway and how to integrate this to EBS R12, I am not able to find how to integrate this with the existing R12.1.3.
Please someone guide me though this.
Also, I would like to know what benefit could we get with XML Gateway setup when we have the workflows and similar setups already available with R12.1.3, and is there is a way to work out the XML messages inside R12.1.3 without setting up XML Gateway.
Experts please clarify the above and guide me and would highly appreciate for a quick response.
Regards,
SandyHi Sandy,
Did you try the documentation library? The following gives you a detail explanation on how you can setup XML gateway on R12.1.3:
http://docs.oracle.com/cd/B53825_08/current/acrobat/121ecxug.pdf
In addition, also please review notes:
Oracle XML Gateway Release Notes for Release 12.1.3 (Doc ID 1096991.1)
11i - 12 How To Download and Install the Latest Oracle Workflow Builder (Client Tool) and XML Gateway Message Designer for E-Business (Doc ID 261028.1)
Also please review the Forum Search, as this will allow a better understanding.
Forum Search: XML Gateway
Thanks &
Best Regards, -
Using XML functions in SQL Developer
Hi,
I'm using OSD 1.5.3 on a WinXP machine. I love OSD and use it every day! But I think i found a little bug. When you use some Oracle XML functions like (XMLELEMENTS and XMLAGG) in your query (these functions return CLOB values) it hangs OSD.
For Example:
SELECT XMLELEMENT("Relation",
XMLELEMENT("Name", 'Dennis'),
XMLELEMENT("DateOfBirth", '09/28/1975')
) as Relation
FROM DUAL;
Are there some parameters I can set to prevent this, or is this a bug?
Kind Regards,
D.Your query works fine for me from SQL Dev 1.5.3 (JDK 1.6.0_06), using either a JDBC or TNS connection (Oracle Client 9.2) to a 10.2.0.3 DB. Another thing which I have no idea if it is relevant (someone else may be able to say) is the following line from Help > About > Properties:
oracle.xdkjava.compatibility.version 9.0.4
Given that it works fine over TNS connections from SQL*Plus and PL/SQL Developer, I would assume that it is something related to your SQL Developer setup, unless you are using a different version of the Oracle client for these tools.
theFurryOne
Maybe you are looking for
-
Error "Agreement item contains a different material"
Hi Expert, i hit an error "Agreement item contains a different material" when i use Control key PM02 withAgreement. Please advise how to solve this. Thanks Regards
-
MOS-01012 during Oracle Pre-Load phase system copy
Hello, The problem is in phase 'Oracle Pre-Load Actions', we have error: MOS-01012 PROBLEM: '/sapmnt/Q02/exe/saplicense -R3Setup Q02 "OMLRUURS" TRACE=2' returned with '254' which is not a defined as a success code. Homogenous system copy, AIX, ORA 9
-
I tried all kinds of ideas. Turning off the firewall and antivirus didn't work. I tried installing itunes with the firewall off. That didn't work. I have three conputers that are affected. Anyone else have any ideas?
-
1310 root bridge w/ wireless clients
I am having an issue with a 1310 in root bridge with wireless clients mode. I have the bridge connected to another bridge in non-root bridge mode and everything is working fine on that end on ethernet. My issue is the wireless one the frirst bridge
-
I am stuck with a problem and I cannot figure it out. I need to be able to extract data based on the records in the BSIS table which do NOT have a corrosponding entries in the BSIK or the BSID table. I need only the GL records. I am trying the code b