Hi Guys,
I've just noticed inconsistency between behavior of conversion of object/collection data to XMLTYPE between 11g R2 and 12.1/12.2 database.
Testcase:
create or replace type test_dummy_object as object (
id number,
"name" varchar2(30),
"Value" varchar2(30)
)
/
select xmlserialize(content xmltype(anydata.convertObject( test_dummy_object(1, null, '0') )) indent SHOW DEFAULTS) from dual union all
select xmlserialize(content xmltype(anydata.convertObject( test_dummy_object(1, null, '0') )) indent HIDE DEFAULTS) from dual union all
select xmltype(anydata.convertObject( test_dummy_object(1, null, '0') )).getclobval() from dual union all
select xmltype(test_dummy_object(1, null, '0')).getclobval() from dual union all
select xmltype.createxml(test_dummy_object(1, null, '0')).getclobval() from dual;
On 11g R2 XE I get:
"<TEST_DUMMY_OBJECT>
<ID>1</ID>
<Value>0</Value>
</TEST_DUMMY_OBJECT>
"
"<TEST_DUMMY_OBJECT>
<ID>1</ID>
<Value>0</Value>
</TEST_DUMMY_OBJECT>
"
<TEST_DUMMY_OBJECT><ID>1</ID><Value>0</Value></TEST_DUMMY_OBJECT>
<TEST_DUMMY_OBJECT><ID>1</ID><Value>0</Value></TEST_DUMMY_OBJECT>
<TEST_DUMMY_OBJECT><ID>1</ID><Value>0</Value></TEST_DUMMY_OBJECT>
On 12.1 and 12.2 I get however additional "<name/>" TAG that represents the NULL value of NAME attribute in type.
I like the new feature but the question is:
How can I get consistency between 11.2 and 12 databases for handling NULL Object Attribute/Column Value when using XMLTYPE as a container for object/cursor data?
I cant find a way to control how XMLTYPE is handling null Object attributes or cursor column values.
I spoke to the XML product manager. There's no way to control it.
But any XML processor should be fine with either, no ?