![]() The possibility of using EVALNAME is an Oracle extension to standard SQL/XML function XMLElement. However it is defined, the identifier must not be NULL or else an error is raised. The root-element identifier argument can be defined using a literal identifier ( identifier, in Figure 18-1) or by EVALNAME followed by an expression ( value_expr) that evaluates to an identifier. The first argument to function XMLElement defines an identifier that names the root XML element to be created. These keywords are Oracle extensions to standard SQL/XML functions XMLElement and XMLAttributes. ![]() In this canonical mapping, user-defined data-type attributes are mapped to XML elements.ĭescription of "Figure 18-1 XMLELEMENT Syntax"įor an explanation of keywords ENTITYESCAPING and NOENTITYESCAPING, see "Escaping Characters in Generated XML Data". This operates on groups of relational rows, aggregating several XML documents into one.Īll of the XML-generation SQL functions convert scalars and user-defined data-type instances to their canonical XML format. This operates on relational rows, generating XML documents. Other XML-generating SQL functions presented in this section are Oracle-specific (not part of the SQL/XML standard): Please refer to for the latest information about SQL/XML functions, including XMLQuery and XMLTable. It is very general and is referred to in this book as a SQL/XML query and access function. The use of XMLQuery is not limited to publishing XML data. You can also construct XML data using the SQL/XML function XMLQuery. The standard XML-generation functions are also known as SQL/XML publishing functions. XMLELEMENT and XMLATTRIBUTES SQL/XML Functions Most of these functions belong to the SQL/XML standard. XMLELEMENT("Hiredate", e.This section describes SQL functions that you can use to construct XML data. ![]() WHERE d.department_id = e.department_id) as "Dept_name")), (SELECT d.department_name FROM departments d XMLELEMENT("Dept", XMLATTRIBUTES(e.department_id, SELECT XMLELEMENT("Emp", XMLATTRIBUTES(e.employee_id, e.last_name), As a result, the XML returned uses the column name last_name as the default.įinally, the next example uses a subquery within the XML_attributes_clause to retrieve information from another table into the attributes of an element: Notice that the AS identifier clause was not specified for the last_name column. XMLELEMENT("Salary", e.salary)) AS "Emp Element" XMLATTRIBUTES(e.employee_id AS "ID", e.last_name), The following similar example uses the XMLElement function with the XML_attributes_clause to create nested XML elements with attribute values for the top-level element: XMLELEMENT("Hiredate", e.hire_date)) as "Result"įROM employees e WHERE employee_id > 200 SELECT XMLELEMENT("Emp", XMLELEMENT("Name", The following example produces an Emp element for a series of employees, with nested elements that provide the employee's name and hire date: If you specify an alias for value_expr using the AS clause, then the c_alias or the evaluated value expression ( EVALNAME value_expr) can be up to 4000 characters if the initialization parameter MAX_STRING_SIZE = STANDARD, and 32767 characters if MAX_STRING_SIZE = EXTENDED. The type of value_expr cannot be an object type or collection. In the XML_attributes_clause, if the value_expr is null, then no attribute is created for that value expression. The objects that make up the element content follow the XMLATTRIBUTES keyword. It can be up to 4000 characters if the initialization parameter MAX_STRING_SIZE = STANDARD, and 32767 characters if MAX_STRING_SIZE = EXTENDED. The identifier does not have to be a column name or column reference. In the latter case, the value expression is evaluated and the result, which must be a string literal, is used as the identifier. You can do this by specifying identifier, which is a string literal, or by specifying EVALNAME value_expr. You must specify a value for Oracle Database to use an the enclosing tag. The XMLElement function is typically nested to produce an XML document with a nested structure, as in the example in the following section.įor an explanation of the ENTITYESCAPING and NONENTITYESCAPING keywords, refer to Oracle XML DB Developer's Guide. XMLElement is similar to SYS_XMLGen except that XMLElement can include attributes in the XML returned, but it does not accept formatting using the XMLFormat object. XMLElement takes an element name for identifier or evaluates an element name for EVALNAME value_expr, an optional collection of attributes for the element, and arguments that make up the content of the element.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |