Problem with XMLElement using cast&multiset null values [message #425877] |
Mon, 12 October 2009 14:48 |
paranoyakX
Messages: 3 Registered: October 2009 Location: TURKEY
|
Junior Member |
|
|
Hi All,
I am generating XML using XmlElement, cast&multiset operators but it is not generete null values nodes.
For Ex:
Select XmlElement("Node", Loc).GetClobVal() From Scott.dept where deptno = 40
this returns <Node>BOSTON</Node>
I insert a new record which is loc field is null
Insert into Scott.dept values (50, 'DUMMY', Null);
Commit;
Select XmlElement("Node", Loc).GetClobVal() From Scott.dept where deptno = 50;
this returns <Node></Node>
This is what i want, but if I use a Cast & Multiset Null value nodes are not being created, like that:
create type t_type as object (Dname varchar2(20), loc number);
create type t_list_type as table of t_type;
Select XmlElement("Node", Cast(Multiset(Select DName, Loc From Scott.dept Where deptno = 50) As T_List_Type)).GetClobVal()
From Dual;
and this returns <Node><T_LIST_TYPE><T_TYPE><DNAME>DUMMY</DNAME></T_TYPE></T_LIST_TYPE></Node>
as you see here there is no LOC node... how could i provide that this node to be generated?
thanks.
[Updated on: Mon, 12 October 2009 14:56] Report message to a moderator
|
|
|
|
Re: Problem with XMLElement using cast&multiset null values [message #425932 is a reply to message #425877] |
Tue, 13 October 2009 04:04 |
paranoyakX
Messages: 3 Registered: October 2009 Location: TURKEY
|
Junior Member |
|
|
as if that I found a kind of solution. for null values if I use whitespace char, I got what i want like that
Select XmlRoot(XmlElement("Node", Cast(Multiset(Select DName, Nvl(Loc, ' ') From Scott.dept Where deptno = 50) As T_List_Type)), version '1.0').GetClobVal()
From Dual;
this returns
<?xml version="1.0"?>
<Node>
<T_LIST_TYPE>
<T_TYPE>
<DNAME>DUMMY</DNAME>
<LOC/>
</T_TYPE>
</T_LIST_TYPE>
</Node>
but ofcourse this is not working for Number fields
PS: in my first message, my first type is wrong, sorry for that, right type is like that
create or replace type t_type as object (Dname varchar2(20), loc Varchar2(13));
second variable would be varchar
[Updated on: Tue, 13 October 2009 04:09] Report message to a moderator
|
|
|