Output from XQuery with xmlForest is Missing the Tag in 11g (Doc ID 1388688.1)

Last updated on FEBRUARY 04, 2013

Applies to:

Oracle Database - Enterprise Edition - Version 11.1.0.7 to 11.2.0.3 [Release 11.1 to 11.2]
Information in this document applies to any platform.

Symptoms

XQuery with xmlForest ... AS "tag" returns different results in 10g versus 11g:

SQL> select version from v$instance;

VERSION
-----------------
10.2.0.5.0

SQL> SELECT xmlelement("mydata",
  2         (SELECT xmlforest(user_id, username) FROM all_users WHERE username = 'SYS') AS "my_user")
  3 FROM dual;

XMLELEMENT("MYDATA",(SELECTXMLFOREST(USER_ID,USERNAME)FROMALL_USERSWHEREUSERNAME
--------------------------------------------------------------------------------
<mydata><my_user><USER_ID>0</USER_ID><USERNAME>SYS</USERNAME></my_user></mydata>
SQL> select version from v$instance;

VERSION
-----------------
11.2.0.3.0

SQL> SELECT xmlelement("mydata",
  2         (SELECT xmlforest(user_id, username) FROM all_users WHERE username = 'SYS') AS "my_user")
  3 FROM dual;

XMLELEMENT("MYDATA",(SELECTXMLFOREST(USER_ID,USERNAME)FROMALL_USERSWHEREUSERNAME
--------------------------------------------------------------------------------
<mydata><USER_ID>0</USER_ID><USERNAME>SYS</USERNAME></mydata>

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms