Contents Index XMLFOREST function [String] YEARS function [Date and time]

ASA SQL Reference
  SQL Functions
    Alphabetical list of functions

XMLGEN function [String]


Function 

Generates an XML value based on an XQuery constructor.

Syntax 

XMLGEN ( xquery-constructorcontent-expression [ AS variable-name ],... )

Parameters 

xquery-constructor    An XQuery constructor. The XQuery constructor is an item defined in the XQuery language. It gives a syntax for constructing XML elements based on XQuery expressions. The xquery-constructor argument must be a well-formed XML document with one or more variable references. A variable reference is enclosed in curly braces and must be prefixed with a $ and have no surrounding white space. For example:

SELECT XMLGEN('<a>{$x}</a>', 1 AS x)

content-expression    A variable. You can specify multiple content-expression arguments. The optional variable-name argument is used to name the variable. For example,

SELECT XMLGEN( '<emp emp_id="{$emp_id}"><start_date>{$x}
                </start_date></emp>',
               emp_id,
               start_date AS x
             )
FROM employee
Usage 

Computed constructors as defined in the XQuery specification are not supported by XMLGEN.

When you execute a query that contains XMLGEN, data in BINARY, LONG BINARY, IMAGE, and VARBINARY columns is automatically returned in base64-encoded format.

Element content is always quoted unless the data type is XML. Invalid element and attribute names are also quoted.

For information about quoting and the XMLGEN function, see Invalid names and SQL/XML.

Standards and compatibility 
See also 

Using the XMLGEN function

Example 

The following example generates an <emp> element, as well as <last_name>, <first_name>, and <start_date> elements for each employee.

SELECT XMLGEN ( '<emp emp_id="{$emp_id}">
                  <last_name>="{$emp_lname}"</last_name>
                  <first_name>="{$emp_fname}"</first_name>
                  <start_date>="{$start_date}"</start_date>
               </emp>',
               emp_id,
               emp_lname,
               emp_fname,
               start_date
              ) AS employee_list
FROM employee

Contents Index XMLFOREST function [String] YEARS function [Date and time]