SQL Dialects Reference/SQL XML
SQL/XML functions
SQLX better known as SQL/XML is an ISO standard (ISO/IEC 9075-1) whose extensions that are part of the SQL 2003 standard.
| Function | Description | DB2 | SQLite | MonetDB | MySQL | PostgreSQL | Firebird | OpenLink Virtuoso | Oracle | MSSQL |
|---|---|---|---|---|---|---|---|---|---|---|
| Version | Software Version(s) Supported | V9 | N/A | V11+ | Planned | 8.3+ | N/A | 3.5-4.x | 9-10x | Proprietary XML Extensions |
| XMLElement() | Create an XML Element | XMLElement() | N/A | xmlelement() | Planned | xmlelement() | N/A | XMLElement() | XMLElement() | .query()[1] |
| XMLForest() | Create an XML Fragment from passed-in components. | XMLForest() | N/A | xmlforest() | xmlforest() | Planned (patch exists) | N/A | XMLForest() | XMLForest() | FOR XML clause[2] |
| XMLColAttVal() | Create an XML fragment and then expands the resulting XML so that each XML fragment has the name "column" with the attribute "name" | N/A | N/A | Planned | Planned | N/A | XMLColAttVal() | XMLColAttVal() | FOR XML clause[2] | |
| ExtractValue() | Takes as arguments an XMLType instance and an XPath expression and returns a scalar value of the resultant node. | N/A | N/A | Planned | Planned | N/A | ExtractValue() | ExtractValue() | .value()[3] | |
| XMLTransform() | Takes as arguments an XMLType instance and an XSL style sheet, which is itself a form of XMLType instance. It applies the style sheet to the instance and returns an XMLType. | N/A | N/A | Planned | Planned | N/A | XMLTransform() | XMLTransform() | N/A[4] | |
| XMLSequence() | Takes input and returns either a varray of the top-level nodes in the XMLType, or an XMLSequence type an XML document for each row of the cursor. | N/A | xmlsequence() | Planned | Planned | N/A | XMLSequence() | XMLSequence() | .nodes()[5] | |
| XMLConcat() | Takes as input a series of XMLType instances, concatenates the series of elements for each row, and returns the concatenated series. | XMLConcat | N/A | N/A | Planned | Planned (patch exists) | N/A | XMLConcat() | XMLConcat() | N/A[6] |
| UpdateXML() | Takes as arguments an XMLType instance and an XPath-value pair, and returns an XMLType instance with the updated value. | N/A | N/A | Planned | Planned | N/A | UpdateXML() | UpdateXML() | .modify()[7] |
Notes
- ↑ The MSSQL 2005 and higher
xmldata type.query()method performs this function. - ↑ ab The MSSQL 2000 and higher
FOR XMLclause of the SQLSELECTstatement performs a similar function. - ↑ The MSSQL 2005 and higher
xmldata type.value()method performs this function. - ↑ In MSSQL 2005 and higher the
xmldata type and SQLCLR can be used to create functions/procedures that simulate this functionality. - ↑ The MSSQL 2005 and higher
xmldata type.nodes()method performs this function. - ↑ In MSSQL 2005 and higher the
+string concatenation operator can be used in conjunction with explicit conversions ofxmldata type instances to character data types to simulate this function. - ↑ The MSSQL 2005 and higher
xmldata type.modify()method performs this function using XML DML.