Skip Headers
Oracle® Data Provider for .NET Developer's Guide
10g Release 2 (10.2)

Part Number B14307-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

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#
/* -- If HR account is being locked, you need to log on as a DBA
   -- to unlock the account first. Unlock a locked users account:
   
   ALTER USER hr ACCOUNT UNLOCK; 
*/
 
using System;
using Oracle.DataAccess.Client;
 
class OracleXmlSavePropertiesSample
{
  static void Main()
  {
    string[] KeyColumnsList = null;
    string[] UpdateColumnsList = null;
    int rows = 0;
      
    // Create the connection.
    string constr = "User Id=hr;Password=hr;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
      
    // Create the command.
    OracleCommand cmd = new OracleCommand("", con);
      
    // 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>1982-01-23T00:00:00.000</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>1982-01-23T00:00:00.000</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;
    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();
    con.Close();
    con.Dispose();
  }
}

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll


OracleXmlSaveProperties Members

OracleXmlSaveProperties members are listed in the following tables:

OracleXmlSaveProperties Constructor

OracleXmlSaveProperties constructors are listed in Table 6-7

Table 6-7 OracleXmlSaveProperties Constructor

Constructor Description
OracleXmlSaveProperties Constructor Instantiates a new instance of the OracleXmlSaveProperties class

OracleXmlSaveProperties Properties

The OracleXmlSaveProperties properties are listed in Table 6-8.

Table 6-8 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 6-9.

Table 6-9 OracleXmlSaveProperties Public Methods

Name Description
Clone Creates a copy of an OracleXmlSaveProperties object


OracleXmlSaveProperties Constructor

The OracleXmlSaveProperties constructor instantiates a new instance of OracleXmlSaveProperties class.

Declaration

// C#
public OracleXmlSaveProperties;

OracleXmlSaveProperties Properties

The OracleXmlSaveProperties properties are listed in Table 6-10.

Table 6-10 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

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.

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.

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.

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; …".


OracleXmlSaveProperties Public Methods

The OracleXmlSaveProperties public methods are listed in Table 6-11.

Table 6-11 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