The oldest posts, are written in Italian. If you are interested and you want read the post in English, please use Google Translator. You can find it on the right side. If the translation is wrong, please email me: I'll try to translate for you.

martedì, settembre 19, 2017

Using XML 11: XMLElement

From [1]. The SQL/XML standard function XMLElement constructs XML elements from relational data. It takes as arguments an element name, an optional collection of attributes for the element, and zero or more additional arguments that make up the element content. It returns an XMLType instance.

The first argument to function XMLElement defines an identifier that names the root XML element to be created. The root-element identifier argument can be defined and, if it is defined, the identifier must not be NULL or else an error is raised.

This is the syntax:

I want to do a very simple test. I use the ALL_USERS view, in order to the run the first select.

Let's reformat the output

Ok. How you can see, the XMLElement, transform the column in a XML. Let's see more on the ALL_USERS view:

I add a second column in my select (green and red).

Because of DATE data type, I change to output using the TO_CHAR function

Really simple. But I can put an XMLElement (gray and green) inside another one (red)

So I obtain a more complex XML.


Part10 Index Part12

Nessun commento: