Skip Headers

Oracle® Data Provider for .NET Developer's Guide
Release 9.2.0.4

Part Number B10961-01
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to beginning of chapter Go to next page

Oracle.DataAccess.Client Namespace, 23 of 30


OracleXmlSaveProperties Class

An OracleXmlSaveProperties object represents the XML properties used by the OracleCommand class when the XmlCommandType property is Insert, Update, or Delete.

Class Inheritance

Object

  OracleXmlSaveProperties

Declaration
public sealed class OracleXmlSaveProperties : ICloneable

Thread Safety

All public static methods are thread-safe, although instance methods do not guarantee thread safety.

Remarks

OracleXmlSaveProperties can be accessed and modified using the XmlSaveProperties property of the OracleCommand class. Each OracleCommand object has its own instance of the OracleXmlSaveProperties class in the XmlSaveProperties property.

Use the default constructor to get a new instance of OracleXmlSaveProperties. Use the OracleXmlSaveProperties.Clone() method to get a copy of an OracleXmlSaveProperties instance.

Example

This sample demonstrates how to do inserts, updates, and deletes to a relational table or view using an XML document.


// C#
string[] KeyColumnsList = null;
string[] UpdateColumnsList = null;
int rows = 0;

// 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 insert.
cmd.XmlCommandType = OracleXmlCommandType.Insert;

// Set the XML document.
cmd.CommandText = "<?xml version=\"1.0\"?>\n" +  
                  "<ROWSET>\n" +  
                  "  <MYROW num = \"1\">\n" +  
                  "    <EMPLOYEE_ID>1234</EMPLOYEE_ID>\n" +  
                  "    <LAST_NAME>Smith</LAST_NAME>\n" +  
                  "    <EMAIL>Smith@Oracle.com</EMAIL>\n" +  
                  "    <HIRE_DATE>1/1/2003 0:0:0</HIRE_DATE>\n" +  
                  "    <JOB_ID>IT_PROG</JOB_ID>\n" +  
                  "  </MYROW>\n" +  
                  "  <MYROW num = \"2\">\n" +  
                  "    <EMPLOYEE_ID>1235</EMPLOYEE_ID>\n" +  
                  "    <LAST_NAME>Barney</LAST_NAME>\n" +  
                  "    <EMAIL>Barney@Oracle.com</EMAIL>\n" +  
                  "    <HIRE_DATE>1/1/2003 0:0:0</HIRE_DATE>\n" +  
                  "    <JOB_ID>IT_PROG</JOB_ID>\n" +  
                  "  </MYROW>\n" +  
                  "</ROWSET>\n";

// Set the XML save properties.
KeyColumnsList = new string[1];
KeyColumnsList[0] = "EMPLOYEE_ID";

UpdateColumnsList = new string[5];
UpdateColumnsList[0] = "EMPLOYEE_ID";
UpdateColumnsList[1] = "LAST_NAME";
UpdateColumnsList[2] = "EMAIL";
UpdateColumnsList[3] = "HIRE_DATE";
UpdateColumnsList[4] = "JOB_ID";

cmd.XmlSaveProperties.KeyColumnsList = KeyColumnsList;
cmd.XmlSaveProperties.RowTag =  "MYROW";
cmd.XmlSaveProperties.Table =  "employees";
cmd.XmlSaveProperties.UpdateColumnsList = UpdateColumnsList;
cmd.XmlSaveProperties.Xslt =  null;
cmd.XmlSaveProperties.XsltParams =  null;

// Do the inserts.
rows = cmd.ExecuteNonQuery();
Console.WriteLine("rows: " + rows);

// Set the XML command type to update.
cmd.XmlCommandType =  OracleXmlCommandType.Update;

// Set the XML document.
cmd.CommandText = "<?xml version=\"1.0\"?>\n" +  
                  "<ROWSET>\n" +  
                  "  <MYROW num = \"1\">\n" +  
                  "    <EMPLOYEE_ID>1234</EMPLOYEE_ID>\n" +  
                  "    <LAST_NAME>Adams</LAST_NAME>\n" +  
                  "  </MYROW>\n" +  
                  "</ROWSET>\n";

// Set the XML save properties.
KeyColumnsList = new string[1];
KeyColumnsList[0] = "EMPLOYEE_ID";

UpdateColumnsList = new string[1];
UpdateColumnsList[0] = "LAST_NAME";

cmd.XmlSaveProperties.KeyColumnsList = KeyColumnsList;
cmd.XmlSaveProperties.UpdateColumnsList = UpdateColumnsList;

// Do the updates.
rows = cmd.ExecuteNonQuery();
Console.WriteLine("rows: " + rows);

// Set the XML command type to delete.
cmd.XmlCommandType =  OracleXmlCommandType.Delete;

// Set the XML document.
cmd.CommandText = "<?xml version=\"1.0\"?>\n" +  
                  "<ROWSET>\n" +  
                  "  <MYROW num = \"1\">\n" +  
                  "    <EMPLOYEE_ID>1234</EMPLOYEE_ID>\n" +  
                  "  </MYROW>\n" +  
                  "  <MYROW num = \"2\">\n" +  
                  "    <EMPLOYEE_ID>1235</EMPLOYEE_ID>\n" +  
                  "  </MYROW>\n" +  
                  "</ROWSET>\n";

// Set the XML save properties.
KeyColumnsList = new string[1];
KeyColumnsList[0] = "EMPLOYEE_ID";

cmd.XmlSaveProperties.KeyColumnsList = KeyColumnsList;
cmd.XmlSaveProperties.UpdateColumnsList = null;

// Do the deletes.
rows = cmd.ExecuteNonQuery();
Console.WriteLine("rows: " + rows);

// Clean up.
cmd.Dispose();
conn.Close();
conn.Dispose();

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll

See Also:

OracleXmlSaveProperties Members

OracleXmlSaveProperties members are listed in the following tables:

OracleXmlSaveProperties Constructor

OracleXmlSaveProperties constructors are listed in Table 4-123

Table 4-123 OracleXmlSaveProperties Constructor
Constructor Description

OracleXmlSaveProperties Constructor

Instantiates a new instance of the OracleXmlSaveProperties class

OracleXmlSaveProperties Properties

The OracleXmlSaveProperties properties are listed in Table 4-124.

Table 4-124 OracleXmlSaveProperties Properties  
Name Description

KeyColumnsList

Specifies the list of columns used as a key to locate existing rows for update or delete using an XML document

RowTag

Specifies the value for the XML element that identifies a row of data in an XML document

Table

Specifies the name of the table or view to which changes are saved

UpdateColumnsList

Specifies the list of columns to update or insert

Xslt

Specifies the XSL document used for XML transformation using XSLT

XsltParams

Specifies the parameters for the XSLT document specified in the Xslt property

OracleXmlSaveProperties Public Methods

The OracleXmlSaveProperties public methods are listed in Table 4-125.

Table 4-125 OracleXmlSaveProperties Public Methods  
Name Description

Clone

Creates a copy of an OracleXmlSaveProperties object

See Also:

OracleXmlSaveProperties Constructor

The OracleXmlSaveProperties constructor instantiates a new instance of OracleXmlSaveProperties class.

Declaration
// C#
public OracleXmlSaveProperties;

See Also:

OracleXmlSaveProperties Properties

The OracleXmlSaveProperties properties are listed in Table 4-126.

Table 4-126 OracleXmlSaveProperties Properties  
Name Description

KeyColumnsList

Specifies the list of columns used as a key to locate existing rows for update or delete using an XML document

RowTag

Specifies the value for the XML element that identifies a row of data in an XML document

Table

Specifies the name of the table or view to which changes are saved

UpdateColumnsList

Specifies the list of columns to update or insert

Xslt

Specifies the XSL document used for XML transformation using XSLT

XsltParams

Specifies the parameters for the XSLT document specified in the Xslt property

See Also:

KeyColumnsList

This property specifies the list of columns used as a key to locate existing rows for update or delete using an XML document.

Declaration
// C#
public string[] KeyColumnsList {get; set;}
Property Value

The list of columns.

Remarks

Default value is null.

The first null value (if any) terminates the list.

KeyColumnsList usage with XMLCommandType property values:

RowTag

This property specifies the value for the XML element that identifies a row of data in an XML document.

Declaration
// C#
public string RowTag {get; set;}
Property Value

An XML element name.

Remarks

The default value is ROW.

Each element in the XML document identifies one row in a table or view.

If RowTag is set to "" or null, no row tag is used in the XML document. In this case, the XML document is assumed to contain only one row.

See Also:

Table

This property specifies the name of the table or view to which changes are saved.

Declaration
// C#
public string Table {get; set;}
Property Value

A table name.

Remarks

Default value is null.

The property must be set to a valid table or view name.

See Also:

UpdateColumnsList

This property specifies the list of columns to update or insert.

Declaration
// C#
public string[] UpdateColumnsList {get; set;}
Property Value

A list of columns.

Remarks

Default value is null.

The first null value (if any) terminates the list.

UpdateColumnList usage with XMLCommandType property values:

Xslt

This property specifies the XSL document used for XML transformation using XSLT.

Declaration
// C#
public string Xslt {get; set;}
Property Value

The XSL document used for XML transformation.

Remarks

Default = null.

The XSL document is used for XSLT transformation of a given XML document. The transformed XML document is used to save changes to the table or view.

See Also:

XsltParams

This property specifies the parameters for the XSLT document specified in the Xslt property.

Declaration
// C#
public string XsltParams {get; set;}
Property Value

The parameters for the XSLT document .

Remarks

Default is null.

This property is a string delimited by semicolons in "name=value" pairs of the form "param1=value1; param2=value2; ...".

See Also:

OracleXmlSaveProperties Public Methods

The OracleXmlSaveProperties public methods are listed in Table 4-127.

Table 4-127 OracleXmlSaveProperties Public Methods  
Name Description

Clone

Creates a copy of an OracleXmlSaveProperties object

Clone

This method creates a copy of an OracleXmlSaveProperties object.

Declaration
// C#
public object Clone();
Return Value

An OracleXmlSaveProperties object

Implements

ICloneable

See Also:

Oracle Data Provider Enumerations

The following is a list of enumerations that Oracle Data Provider for .NET provides.


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2002, 2003 Oracle Corporation.

All Rights Reserved.
Go To Table Of Contents
Contents
Go To Index
Index