Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 4 XML Mapping Functions [Table of Contents] forxmlj, forxmldtdj, forxmlschemaj, forxmlallj

XML Services in Adaptive Server Enterprise

[-] Chapter 4 XML Mapping Functions
[-] for xml clause

for xml clause

Specifies a SQL select statement that returns an XML representation of the result set.

Syntax

select ::=
     select [ all | distinct ] select_list
     [into_clause ]
     [where_clause ]
     [group_by_clause ]
     [having_clause ]
     [order_by_clause ]
     [compute_clause ]
     [read_only_clause ]
     [isolation_clause ]
     [browse_clause ]
     [plan_clause]for_xml_clause::=
    |for xml[option option_string]
 option_string::=basic_character_expression

For more information about option strings, see option_strings: general format.

Description

Options

The general format of the option_string is specified in option_strings: general format. The options for the for_xml_clause are specified in "SQLX Options."

Exceptions

Any SQL exception raised during execution of the basic select statement is raised by the for_xml select. For example, both of the following statements raise a zero divide exception:

select 1/0
select 1/0 for xml

Example

The for_xml clause:

select pub_id, pub_name 
from pubs2.dbo.publishers
for xml
go


 <resultset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <row>
   <pub_id>0736</pub_id>
   <pub_name>NewAgeBooks</pub_name>
 </row>

 <row>
   <pub_id>0877</pub_id>
   <pub_name>Binnet & Hardley</pub_name>
 </row>

 <row>
   <pub_id>1389</pub_id>
   <pub_name>Algodata Infosystems</pub_name>
 </row>

 </resultset> 


Chapter 4 XML Mapping Functions [Table of Contents] forxmlj, forxmldtdj, forxmlschemaj, forxmlallj