During a mind exercise with some of my OTN XMLDB forum peers, I discovered (tkprof…), that the non-recursive statement used for, for example the following:
SQL> xquery
2 let $auction := ora:view("XTAB") return
3 for $b in $auction/site/people/person[@id = "person0"]
4 return $b/name/text()
5 /
is internally rewritten to
SQL> SELECT COLUMN_VALUE RESULT_PLUS_XQUERY FROM XMLTABLE
2 ('let $auction := ora:view("XTAB") return
3 for $b in $auction/site/people/person[@id = "person0"]
4 return $b/name/text()')
5 ;
So a “SELECT COLUMN_VALUE RESULT_PLUS_XQUERY FROM XMLTABLE()” wrapper statement is used as a replacement for the SQL*Plus “XQuery” command.
That explains, for instance, why the “heading” formatting as described in the 10gr2 manual regarding XQuery in SQL*Plus works.