| Oracle® Data Provider for .NET Developer's Guide Release 9.2.0.4 Part Number B10961-01 |
|
Oracle.DataAccess.Client Namespace, 22 of 30
An OracleXmlQueryProperties object represents the XML properties used by the OracleCommand class when the XmlCommandType property is Query.
Object
OracleXmlQueryProperties
public sealed class OracleXmlQueryProperties : ICloneable
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
OracleXmlQueryProperties can be accessed, and modified using the XmlQueryProperties property of the OracleCommand class. Each OracleCommand object has its own instance of the OracleXmlQueryProperties class in the XmlQueryProperties property.
Use the default constructor to get a new instance of the OracleXmlQueryProperties. Use the OracleXmlQueryProperties.Clone() method to get a copy of an OracleXmlQueryProperties instance.
This example retrieves relational data as XML.
// C# StreamReader sr = null; // Create the connection. string constr = "User Id=hr;Password=hr;Data Source=orcl"; OracleConnection conn = new OracleConnection(constr); conn.Open(); // Create the command. OracleCommand cmd = new OracleCommand("", conn); // Set the XML command type to query. cmd.XmlCommandType = OracleXmlCommandType.Query; // Set the SQL query. cmd.CommandText = "select * from employees e where e.employee_id = :empno"; // Set command properties that affect XML query behaviour. cmd.BindByName = true; cmd.AddRowid = true; // Bind values to the parameters in the SQL query. Int32 empNum = 205; cmd.Parameters.Add(":empno", OracleDbType.Int32, empNum, ParameterDirection.Input); // Set the XML query properties. cmd.XmlQueryProperties.MaxRows = -1; cmd.XmlQueryProperties.RootTag = "MYROWSET"; cmd.XmlQueryProperties.RowTag = "MYROW"; cmd.XmlQueryProperties.Xslt = null; cmd.XmlQueryProperties.XsltParams = null; // Test query execution without returning a result. int rows = cmd.ExecuteNonQuery(); Console.WriteLine("rows: " + rows); // Get the XML document as an XmlReader. XmlReader xmlReader = cmd.ExecuteXmlReader(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.PreserveWhitespace = true; xmlDocument.Load(xmlReader); Console.WriteLine(xmlDocument.OuterXml); // Change the SQL query, and set the maximum number of rows to 2. cmd.CommandText = "select * from employees e"; cmd.Parameters.Clear(); cmd.XmlQueryProperties.MaxRows = 2; // Get the XML document as a Stream. Stream stream = cmd.ExecuteStream(); sr = new StreamReader(stream, Encoding.Unicode); Console.WriteLine(sr.ReadToEnd()); // Get all the rows. cmd.XmlQueryProperties.MaxRows = -1; // Append the XML document to an existing Stream. MemoryStream mstream = new MemoryStream(32); cmd.ExecuteToStream(mstream); mstream.Seek(0, SeekOrigin.Begin); sr = new StreamReader(mstream, Encoding.Unicode); Console.WriteLine(sr.ReadToEnd()); // Clean up. cmd.Dispose(); conn.Close(); conn.Dispose();
Namespace: Oracle.DataAccess.Client
Assembly: Oracle.DataAccess.dll
OracleXmlQueryProperties members are listed in the following tables:
The OracleXmlQueryProperties constructors are listed in Table 4-118.
| Constructor | Description |
|---|---|
|
Instantiates a new instance of the |
The OracleXmlQueryProperties properties are listed in Table 4-119.
The OracleXmlQueryProperties public methods are listed in Table 4-120.
| Name | Description |
|---|---|
|
Creates a copy of an |
The OracleXmlQueryProperties constructor instantiates a new instance of the OracleXmlQueryProperties class.
// C# public OracleXmlQueryProperties();
The OracleXmlQueryProperties properties are listed in Table 4-121.
This property specifies the maximum number of rows from the result set of the query that can be represented in the result XML document.
// C# public int MaxRows {get; set;}
The maximum number of rows.
ArgumentException - The new value for MaxRows is not valid.
Default value is -1.
Possible values are:
This property specifies the root element of the result XML document.
// C# public string RootTag {get; set;}
The root element of the result XML document.
The default root tag is ROWSET.
To indicate that no root tag is be used in the result XML document, set this property to null or "" or String.Empty.
If both RootTag and RowTag are set to null, an XML document is returned only if the result set returns one row and one column.
This property specifies the value of the XML element which identifies a row of data from the result set in an XML document.
// C# public string RowTag {get; set;}
The value of the XML element.
The default is ROW.
To indicate that no row tag is be used in the result XML document, set this property to null or "" or String.Empty.
If both RootTag and RowTag are set to null, an XML document is returned only if the result set returns one row and one column.
This property specifies the XSL document used for XML transformation using XSLT.
// C# public string Xslt {get; set;}
The XSL document used for XML transformation.
Default value is null.
The XSL document is used for XML transformation of the XML document generated from the result set of the query.
This property specifies parameters for the XSL document.
// C# public string XsltParams {get; set;}
The parameters for the XSL document.
Default value is null.
The parameters are specified as a string of "name=value" pairs of the form "param1=value1; param2=value2; ..." delimited by semicolons.
The OracleXmlQueryProperties public methods are listed in Table 4-122.
| Name | Description |
|---|---|
|
Creates a copy of an |
This method creates a copy of an OracleXmlQueryProperties object.
// C# public object Clone();
An OracleXmlQueryProperties object
ICloneable
|
|
![]() Copyright © 2002, 2003 Oracle Corporation. All Rights Reserved. |
|