XML QUERY LANGUAGES: XQUERY AND XPATH xml.valuetakes

XML QUERY LANGUAGES: XQUERY AND XPATH xml.valuetakes an XQuery query as input and returns a SQL type as a scalar value. xml.existtakes an XQuery query as input and returns 0, 1, or NULL, depending on whether the query returns an empty sequence (0), a sequence with at least one item (1), or the column is NULL. xml.nodestakes an XQuery query as input and returns a one- column rowset that contains references to XML documents with the XQuery context set at the matching node. Currently, SQL Server 2005 XQuery is aligned to the November 2003 XQuery draft, with some implementation restrictions. As SQL Server 2005 approaches RTM (release to manufacturing), the dialect may be aligned to a later draft. Although the XQuery language itself can be used to produce complex documents, as we ve seen, this functionality is really only used to a great extent in SQL Server in the xml.query function. When using xml.value and xml.exist, we ll really be using simple XPath 2.0 expressions rather than complex XQuery with sequences, constructors, formatting information, and so on. Although we could use more complex XQuery, the reason for this is that xml.value can only return a sequence containing a single scalar value (it cannot return an XML data type), and xml.exist is used to check for existence. So let s cover them first. xml.exist(string xquery-text) The xml.exist function refers to a single column or variable of the XML data type. For example, if we define the following table: CREATE TABLE xml_tab( the_id INTEGER PRIMARY KEY IDENTITY, xml_col XML) and fill the table with some rows, the xml.exist function will search the XML column specified, looking for data that matches the given XQuery expression. For each row, if the row contains matching data in the specified column, the function returns true (1). For example, if the rows inserted look like this: INSERT xml_tab VALUES( ) INSERT xml_tab VALUES( ) INSERT xml_tab VALUES( ) GO

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.