Databases Reference
In-Depth Information
XMLTEXT
XMLTEXT function can be used to create a text node in an XML value. The
input to this function is the value of the text node.
Functions to concatenate or aggregate more than one node include:
XMLCONCAT
XMLCONCAT function concatenates the multiple XML nodes and returns the
sequence of the nodes as a result. XMLCONCAT is a scalar function and only
returns one XML value per row of the input expression. It takes only the
existing XML value or column as input.
XMLFOREST
XMLFOREST function creates a new list of element nodes. It takes the values
of any data type as input and creates an element for each value given.
XMLAGG
XMLAGG is an aggregate function. It takes a set of rows of XML values and
produces a single XML result.
Example 2-22 shows how to use these functions to create an XML value from
relational and XML columns. The example combines the information and reviews
for a movie in a single XML value.
Example 2-22 Using publishing functions
select XMLELEMENT(NAME "moviereview",
XMLCONCAT(movies.info,
XMLELEMENT(NAME "reviews",XMLATTRIBUTES
(moviereview.reviewid as "id"),
XMLCONCAT(T.UserReview, T.CriticsReview))))
from movies, moviereview,xmltable('$d/movie/reviews' passing
moviereview.review as "d"
columns
UserReview XML PATH './UserReview',
CriticsReview XML PATH './CriticsReview') as T
where XMLEXISTS('$d/movie[@id=$id]' passing movies.id as
"id",moviereview.review as "d")
Search WWH ::




Custom Search