PK kUIoa,mimetypeapplication/epub+zipPKkUIOEBPS/extenRest.htmb/ Oracle Data Provider for .NET Server-Side Features

Limitations and Restrictions on ODP.NET Within .NET Stored Procedure

This section covers important concepts that apply when Oracle Data Provider for .NET is used within a .NET stored procedure.

Implicit Database Connection

Within a .NET stored procedure, an implicit database connection is available for use to access Oracle data. This implicit database connection should be used rather than establishing a user connection because the implicit database connection is already established by the caller of the .NET stored procedure, thereby minimizing resource usage.

To obtain an OracleConnection object in a .NET stored procedure that represents the implicit database connection, set the ConnectionString property of the OracleConnection object to "context connection=true" and invoke the Open method. Other connection string attributes cannot be used in conjunction with "context connection" when it is set to true.

The availability of the implicit database connection can be checked at runtime through the static OracleConnection.IsAvailable property. This property always returns true when Oracle Data Provider for .NET is used within a .NET stored procedure. Otherwise, false is returned.

Only one implicit database connection is available within a .NET stored procedure invocation. To establish more connections in addition to the implicit database connection, an explicit connection must be created. When the Close method is invoked on the OracleConnection that represents the implicit database connection, the connection is not actually closed. Therefore, the Open method of the same or another OracleConnection object can be invoked to obtain the connection that represents the implicit database connection.

The implicit database connection can only be acquired by the Open method invocation by a native Oracle thread that initially invokes the .NET stored procedure. However, threads spawned from the native Oracle thread can use implicit database connections that are obtained by the native Oracle thread.


See Also:

"IsAvailable"

Transaction Support

The .NET stored procedure execution automatically inherits the current transaction on the implicit database connection. However, no explicit transaction can be started, committed, or rolled back inside a .NET stored procedure. For example, OracleConnection.BeginTransaction is not allowed for .NET stored procedure. Neither local nor distributed transaction support is available for a .NET stored procedure. If you have enlisted a client connection in a distributed transaction and call a .NET stored procedure or a function, an error occurs.

If a .NET stored procedure or function performs operations on the database that are required to be part of a transaction, the transaction must be started prior to calling the .NET stored procedure. Any desired commit or rollback must be performed after returning from the .NET stored procedure or function.

.NET stored procedures do not support distributed transactions. If you have enlisted a client connection in a distributed transaction and call a .NET stored procedure or function, an error occurs.

The following example consists of a client application and a .NET stored procedure, InsertRecordSP, that inserts an employee record into an EMP table.

Example (.NET Stored Procedure)

using System;
using System.Data;
using Oracle.DataAccess.Client;
// This class represents an Oracle .NET stored procedure that inserts
// an employee record into an EMP table of SCOTT schema.
public class InsertRecordSP
{
    // This procedure will insert a row into the emp database
    // For simplicity we are using only two parameters, the rest are hard coded
    public static void InsertRecord( int EmpNo, string EmpName )
    {
        if(OracleConnection.IsAvailable == true )
        {
            OracleConnection conn = OracleConnection("context connection=true");
            conn.Open();
            // Create new command object from connection context
            OracleCommand Cmd = conn.CreateCommand();
            Cmd.CommandText = "INSERT INTO EMP( EMPNO, ENAME, JOB," +
                "MGR, HIREDATE, SAL, COMM, DEPTNO ) " +
                "VALUES ( :1, :2, 'ANALYST', 7566, " +
                "'06-DEC-04', 5000, 0, 20 )";
            Cmd.Parameters.Add( ":1", OracleDbType.Int32,
                EmpNo, ParameterDirection.Input );
            Cmd.Parameters.Add( ":2", OracleDbType.Varchar2,
                EmpName, ParameterDirection.Input );
            Cmd.ExecuteNonQuery();
        }
    }
}

Example (Client Application)

The example enters new employee, Bernstein, employee number 7950, into the EMP table.

// C#
// This sample demonstrates how to start the transaction with ODP.NET client 
// application and execute an Oracle .NET stored procedure that performs
// a DML operation. Since .NET stored procedure inherits the current
// transaction from the implicit database connection,  DML operation 
// in .NET stored procedure will not be in auto-committed mode.
// Therefore, it is up to the client application to do a COMMIT or ROLLBACK
// after returning from .NET stored procedure
using System;
using System.Data;
using Oracle.DataAccess.Client;
// In this class we are starting a transaction on the client side and
// executing a .NET stored procedure, which inserts a record into EMP
// table and then verifies record count before and after COMMIT statement
class TransactionSample
{
    static void Main(string[] args)
    {
        OracleConnection Conn = null;
        OracleTransaction Txn = null;
        OracleCommand Cmd = null;
        try
        {
            Console.WriteLine( "Sample: Open DB connection in non auto-committed" +
           "mode," +
                "DML operation performed by .NET stored " +
                "procedure doesn't have an effect before COMMIT " +
                "is called." );
            // Create and Open oracle connection
            Conn = new OracleConnection();
            Conn.ConnectionString = "User Id=scott;Password=tiger;" +
                "Data Source=oracle;";
            Conn.Open();
            // Start transaction
            Txn = Conn.BeginTransaction( IsolationLevel.ReadCommitted );
            // Create command object
            Cmd = new OracleCommand();
            Cmd.Connection = Conn;
            Cmd.CommandType = CommandType.StoredProcedure;
            Cmd.CommandText = "InsertRecord"; // .NET Stored procedure
            // Parameter settings
            OracleParameter EmpNoPrm = Cmd.Parameters.Add(
                "empno", OracleDbType.Int32 );
            EmpNoPrm.Direction = ParameterDirection.Input;
            EmpNoPrm.Value = 7950;
            OracleParameter EmpNamePrm = Cmd.Parameters.Add(
                "ename", OracleDbType.Varchar2, 10 );
            EmpNamePrm.Direction = ParameterDirection.Input;
            EmpNamePrm.Value = "Bernstein";
            // Execute .NET stored procedure
            Cmd.ExecuteNonQuery();
            Console.WriteLine( "Number of record(s) before COMMIT {0}",
                RecordCount() );
            Txn.Commit();
            Console.WriteLine( "Number of record(s) after COMMIT {0}",
                RecordCount() );
        }
        catch( OracleException OE )
        {
            Console.WriteLine( OE.Message );
        }
        finally
        {
            // Cleanup objects
            if( null != Txn )
                Txn.Dispose();
            if( null != Cmd )
                Cmd.Dispose();
            if( null != Conn && Conn.State == ConnectionState.Open )
                Conn.Close();
        }
    }
    static int RecordCount()
    {
        int EmpCount = 0;
        OracleConnection Conn = null;
        OracleCommand Cmd = null;
        try
        {
            Conn = new OracleConnection( "User Id=scott;Password=tiger;" +
                "Data Source=oracle;" );
            Conn.Open();
            Cmd = new OracleCommand( "SELECT COUNT(*) FROM EMP;", Conn );
            Object o = Cmd.ExecuteScalar();
            EmpCount = Convert.ToInt32(o.ToString());
        }
        catch( OracleException OE )
        {
            Console.WriteLine( OE.Message );
        }
        finally
        {
            if( null != Cmd )
                Cmd.Dispose();

Unsupported SQL Commands

Transaction controls commands such as COMMIT, ROLLBACK, and SAVEPOINT are not supported in a .NET stored procedure.

Data definition commands such as CREATE and ALTER are not supported with an implicit database connection, but they are supported with an explicit user connection in a .NET stored procedure.

PK5/sg/b/PKkUIOEBPS/OracleParameterClass.htm Oracle Data Provider for .NET Classes

OracleParameter Class

An OracleParameter object represents a parameter for an OracleCommand or a DataSet column.

Class Inheritance

Object

  MarshalByRefObject

    OracleParameter

Declaration

// C#
public sealed class OracleParameter : MarshalByRefObject, IDBDataParameter, 
   IDataParameter, IDisposable, ICloneable

Thread Safety

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

Exceptions

ArgumentException - The type binding is invalid.

Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client; 
using Oracle.DataAccess.Types;
 
class OracleParameterSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    OracleParameter[] prm = new OracleParameter[3];
 
    // Create OracleParameter objects through OracleParameterCollection
    OracleCommand cmd = con.CreateCommand();
 
    cmd.CommandText = "select max(empno) from emp";
    int maxno = int.Parse(cmd.ExecuteScalar().ToString());
 
    prm[0] = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, 
      maxno + 10, ParameterDirection.Input);
    prm[1] = cmd.Parameters.Add("paramEname", OracleDbType.Varchar2, 
      "Client", ParameterDirection.Input);
    prm[2] = cmd.Parameters.Add("paramDeptNo", OracleDbType.Decimal, 
      10, ParameterDirection.Input);
    cmd.CommandText = 
      "insert into emp(empno, ename, deptno) values(:1, :2, :3)";
    cmd.ExecuteNonQuery();
 
    Console.WriteLine("Record for employee id {0} has been inserted.", 
                      maxno + 10);
  }
}

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll


OracleParameter Members

OracleParameter members are listed in the following tables:

OracleParameter Constructors

OracleParameter constructors are listed in Table 5-69.

Table 5-69 OracleParameter Constructors

Constructor Description
OracleParameter Constructors Instantiates a new instance of OracleParameter class (Overloaded)

OracleParameter Static Methods

OracleParameter static methods are listed in Table 5-70.

Table 5-70 OracleParameter Static Methods

Methods Description
Equals Inherited from Object (Overloaded)

OracleParameter Properties

OracleParameter properties are listed in Table 5-71.

Table 5-71 OracleParameter Properties

Name Description
ArrayBindSize Specifies the input or output size of a parameter before or after an Array Bind or PL/SQL Associative Array Bind execution
ArrayBindStatus Specifies the input or output status of a parameter before or after an Array Bind or PL/SQL Associative Array Bind execution
CollectionType
Specifies whether or not the OracleParameter represents a collection, and if so, specifies the collection type
DbType Specifies the datatype of the parameter using the Data.DbType enumeration type
Direction Specifies whether the parameter is input-only, output-only, bi-directional, or a stored function return value parameter
IsNullable This method is a no-op
Offset Specifies the offset to the Value property or offset to the elements in the Value property
OracleDbType Specifies the Oracle datatype
ParameterName Specifies the name of the parameter
Precision Specifies the maximum number of digits used to represent the Value property
Scale Specifies the number of decimal places to which Value property is resolved
Size Specifies the maximum size, in bytes or characters, of the data transmitted to or from the database. For PL/SQL Associative Array Bind, Size specifies the maximum number of elements in PL/SQL Associative Array.
SourceColumn Specifies the name of the DataTable Column of the DataSet
SourceVersion Specifies the DataRowVersion value to use when loading the Value property of the parameter
Status Indicates the status of the execution related to the data in the Value property
Value Specifies the value of the Parameter

OracleParameter Public Methods

OracleParameter public methods are listed in Table 5-72.

Table 5-72 OracleParameter Public Methods

Public Method Description
Clone Creates a shallow copy of an OracleParameter object
CreateObjRef Inherited from MarshalByRefObject
Dispose Releases allocated resources
Equals Inherited from Object (Overloaded)
GetHashCode Inherited from Object
GetLifetimeService Inherited from MarshalByRefObject
GetType Inherited from Object
InitializeLifetimeService Inherited from MarshalByRefObject
ToString Inherited from Object (Overloaded)


OracleParameter Constructors

OracleParameter constructors instantiate new instances of the OracleParameter class.

Overload List:

OracleParameter()

This constructor instantiates a new instance of OracleParameter class.

Declaration

// C#
public OracleParameter();

Remarks

Default Values:

OracleParameter (string, OracleDbType)

This constructor instantiates a new instance of OracleParameter class using the supplied parameter name and Oracle datatype.

Declaration

// C#
public OracleParameter(string parameterName, OracleDbType oraType);

Parameters

Remarks

Changing the DbType implicitly changes the OracleDbType.

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

OracleParameter(string, object)

This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name and parameter value.

Declaration

// C#
public OracleParameter(string parameterName, object obj);

Parameters

Remarks

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

OracleParameter(string, OracleDbType, ParameterDirection)

This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, and parameter direction.

Declaration

// C#
public OracleParameter(string parameterName, OracleDbType type,
   ParameterDirection direction);

Parameters

Remarks

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

OracleParameter(string, OracleDbType, object, ParameterDirection)

This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, value, and direction.

Declaration

// C#
public OracleParameter(string parameterName, OracleDbType type, object obj, 
   ParameterDirection direction);

Parameters

Remarks

Changing the DbType implicitly changes the OracleDbType.

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

OracleParameter(string, OracleDbType, int)

This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, and size.

Declaration

// C#
public OracleParameter(string parameterName, OracleDbType type,
   int size);

Parameters

  • parameterName

    The parameter name.

  • type

    The datatype of the OracleParameter.

  • size

    The size of the OracleParameter value.

Remarks

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

  • DbType - String

  • ParameterDirection - Input

  • isNullable - true

  • offset - 0

  • OracleDbType - Varchar2

  • ParameterAlias - Empty string

  • ParameterName - Empty string

  • Precision - 0

  • Size - 0

  • SourceColumn - Empty string

  • SourceVersion - Current

  • ArrayBindStatus - Success

  • Value - null

OracleParameter(string, OracleDbType, int, string)

This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, size, and source column.

Declaration

// C#
public OracleParameter(string parameterName, OracleDbType type, int size, 
  string srcColumn);

Parameters

  • parameterName

    The parameter name.

  • type

    The datatype of the OracleParameter.

  • size

    The size of the OracleParameter value.

  • srcColumn

    The name of the source column.

Remarks

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

  • DbType - String

  • ParameterDirection - Input

  • isNullable - true

  • offset - 0

  • OracleDbType - Varchar2

  • ParameterAlias - Empty string

  • ParameterName - Empty string

  • Precision - 0

  • Size - 0

  • SourceColumn - Empty string

  • SourceVersion - Current

  • ArrayBindStatus - Success

  • Value - null

OracleParameter(string, OracleDbType, int, ParameterDirection, bool, byte, byte, string, DataRowVersion, object)

This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, size, direction, null indicator, precision, scale, source column, source version and parameter value.

Declaration

// C#
public OracleParameter(string parameterName, OracleDbType oraType, 
   int size, ParameterDirection direction, bool isNullable, byte
   precision, byte scale,  string srcColumn, DataRowVersion srcVersion,
   object obj);

Parameters

  • parameterName

    The parameter name.

  • oraType

    The datatype of the OracleParameter.

  • size

    The size of the OracleParameter value.

  • direction

    The ParameterDirection value.

  • isNullable

    An indicator that specifies if the parameter value can be null.

  • precision

    The precision of the parameter value.

  • scale

    The scale of the parameter value.

  • srcColumn

    The name of the source column.

  • srcVersion

    The DataRowVersion value.

  • obj

    The parameter value.

Exceptions

ArgumentException - The supplied value does not belong to the type of Value property in any of the OracleTypes.

Remarks

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

  • DbType - String

  • ParameterDirection - Input

  • isNullable - true

  • offset - 0

  • OracleDbType - Varchar2

  • ParameterAlias - Empty string

  • ParameterName - Empty string

  • Precision - 0

  • Size - 0

  • SourceColumn - Empty string

  • SourceVersion - Current

  • ArrayBindStatus - Success

  • Value - null

OracleParameter(string, OracleDbType, int, object, ParameterDirection)

This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, size, value, and direction.

Declaration

// C#
public OracleParameter(string parameterName, OracleDbType type, int size, 
   object obj, ParameterDirection direction);

Parameters

  • parameterName

    The parameter name.

  • type

    The datatype of the OracleParameter.

  • size

    The size of the OracleParameter value.

  • obj

    The value of the OracleParameter.

  • direction

    The ParameterDirection value.

Remarks

Changing the DbType implicitly changes the OracleDbType.

Unless explicitly set in the constructor, all the properties have the default values.

Default Values:

  • DbType - String

  • ParameterDirection - Input

  • isNullable - true

  • offset - 0

  • OracleDbType - Varchar2

  • ParameterAlias - Empty string

  • ParameterName - Empty string

  • Precision - 0

  • Size - 0

  • SourceColumn - Empty string

  • SourceVersion - Current

  • ArrayBindStatus - Success

  • Value - null


OracleParameter Static Methods

The OracleParameter static method is listed in Table 5-73.

Table 5-73 OracleParameter Static Method

Method Description
Equals Inherited from Object (Overloaded)


OracleParameter Properties

OracleParameter properties are listed in Table 5-74.

Table 5-74 OracleParameter Properties

Name Description
ArrayBindSize Specifies the input or output size of elements in Value property of a parameter before or after an Array Bind or PL/SQL Associative Array Bind execution
ArrayBindStatus Specifies the input or output status of elements in Value property of a parameter before or after an Array Bind or PL/SQL Associative Array Bind execution
CollectionType
Specifies whether or not the OracleParameter represents a collection, and if so, specifies the collection type
DbType Specifies the datatype of the parameter using the Data.DbType enumeration type
Direction Specifies whether the parameter is input-only, output-only, bi-directional, or a stored function return value parameter
IsNullable This method is a no-op
Offset Specifies the offset to the Value property or offset to the elements in the Value property
OracleDbType Specifies the Oracle datatype
ParameterName Specifies the name of the parameter
Precision Specifies the maximum number of digits used to represent the Value property
Scale Specifies the number of decimal places to which Value property is resolved
Size Specifies the maximum size, in bytes or characters, of the data transmitted to or from the database. For PL/SQL Associative Array Bind, Size specifies the maximum number of elements in PL/SQL Associative Array
SourceColumn Specifies the name of the DataTable Column of the DataSet
SourceVersion Specifies the DataRowVersion value to use when loading the Value property of the parameter
Status Indicates the status of the execution related to the data in the Value property
Value Specifies the value of the Parameter

ArrayBindSize

This property specifies the maximum size, in bytes or characters, of the data for each array element transmitted to or from the database. This property is used for Array Bind or PL/SQL Associative Array execution.

Declaration

// C#
public int[] ArrayBindSize {get; set; }

Property Value

An array of int values specifying the size.

Remarks

Default = null.

This property is only used for variable size element types for an Array Bind or PL/SQL Associative Array. For fixed size element types, this property is ignored.

Each element in the ArrayBindSize corresponds to the bind size of an element in the Value property. Before execution, ArrayBindSize specifies the maximum size of each element to be bound in the Value property. After execution, it contains the size of each element returned in the Value property.

For binding a PL/SQL Associative Array, whose elements are of a variable-length element type, as an InputOutput, Out, or ReturnValue parameter, this property must be set properly. The number of elements in ArrayBindSize must be equal to the value specified in the OracleParameter.Size property.

Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client;
 
class ArrayBindSizeSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    OracleParameter[] prm = new OracleParameter[3];
 
    // Create OracleParameter objects through OracleParameterCollection
    OracleCommand cmd = con.CreateCommand();
 
    cmd.CommandText = "select max(empno) from emp";
    int maxno = int.Parse(cmd.ExecuteScalar().ToString());
 
    // Set the ArrayBindCount for Array Binding
    cmd.ArrayBindCount = 2;
 
    prm[0] = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, 
      new int[2] {maxno + 10, maxno + 11}, ParameterDirection.Input);
    prm[1] = cmd.Parameters.Add("paramEname", OracleDbType.Varchar2, 
      new string[2] {"Client1xxx", "Client2xxx"}, ParameterDirection.Input);
    prm[2] = cmd.Parameters.Add("paramDeptNo", OracleDbType.Decimal, 
      new int[2] {10, 10}, ParameterDirection.Input);
 
    // Set the ArrayBindSize for prm[1]
    // These sizes indicate the maximum size of the elements in Value property
    prm[1].ArrayBindSize = new int[2];
    prm[1].ArrayBindSize[0] = 7; // Set ename = "Client1"
    prm[1].ArrayBindSize[1] = 7; // Set ename = "Client2"
 
    cmd.CommandText = 
      "insert into emp(empno, ename, deptno) values(:1, :2, :3)";
 
    cmd.ExecuteNonQuery();
 
    Console.WriteLine("Record for employee id {0} has been inserted.", 
      maxno + 10);
    Console.WriteLine("Record for employee id {0} has been inserted.", 
      maxno + 11);
 
    prm[0].Dispose();
    prm[1].Dispose();
    prm[2].Dispose();
    cmd.Dispose();
 
    con.Close();
    con.Dispose();
  }
}

ArrayBindStatus

This property specifies the input or output status of each element in the Value property before or after an Array Bind or PL/SQL Associative Array execution.

Declaration

// C#
public OracleParameterStatus[] ArrayBindStatus { get; set; }

Property Value

An array of OracleParameterStatus enumerated values.

Exceptions

ArgumentOutofRangeException - The Status value specified is invalid.

Remarks

Default = null.

ArrayBindStatus is used for Array Bind and PL/SQL Associative Array execution only.

Before execution, ArrayBindStatus indicates the bind status of each element in the Value property. After execution, it contains the execution status of each element in the Value property.

CollectionType

This property specifies whether or not the OracleParameter represents a collection, and if so, specifies the collection type.

Declaration

// C#
public OracleCollectionType CollectionType { get; set; }

Property Value

An OracleCollectionType enumerated value.

Exceptions

ArgumentException - The OracleCollectionType value specified is invalid.

Remarks

Default = OracleCollectionType.None. If OracleParameter is used to bind a PL/SQL Associative Array, then CollectionType must be set to OracleCollectionType.PLSQLAssociativeArray.

DbType

This property specifies the datatype of the parameter using the Data.DbType enumeration type.

Declaration

// C#
public DbType DbType {get; set; }

Property Value

A DbType enumerated value.

Implements

IDataParameter

Exceptions

ArgumentException - The DbType value specified is invalid.

Remarks

Default = DbType.String

DbType is the datatype of each element in the array if the OracleParameter object is used for Array Bind or PL/SQL Associative Array Bind execution.

Due to the link between DbType and OracleDbType properties, if the DbType property is set, the OracleDbType property is inferred from DbType.

Direction

This property specifies whether the parameter is input-only, output-only, bi-directional, or a stored function return value parameter.

Declaration

// C#
public ParameterDirection Direction { get; set; }

Property Value

A ParameterDirection enumerated value.

Implements

IDataParameter

Exceptions

ArgumentOutOfRangeException - The ParameterDirection value specified is invalid.

Remarks

Default = ParameterDirection.Input

Possible values: Input, InputOutput, Output, and ReturnValue.

Offset

This property specifies the offset to the Value property.

Declaration

// C#
public int Offset { get; set; }

Property Value

An int that specifies the offset.

Exceptions

ArgumentOutOfRangeException - The Offset value specified is invalid.

Remarks

Default = 0

For Array Bind and PL/SQL Associative Array Bind, Offset applies to every element in the Value property.

The Offset property is used for binary and string datatypes. The Offset property represents the number of bytes for binary types and the number of characters for strings. The count for strings does not include the terminating character if a null is referenced. The Offset property is used by parameters of the following types:

  • OracleDbType.BFile

  • OracleDbType.Blob

  • OracleDbType.LongRaw

  • OracleDbType.Raw

  • OracleDbType.Char

  • OracleDbType.Clob

  • OracleDbType.NClob

  • OracleDbType.NChar

  • OracleDbType.NVarchar2

  • OracleDbType.Varchar2

OracleDbType

This property specifies the Oracle datatype.

Declaration

// C#
public OracleDbType OracleDbType { get; set; }

Property Value

An OracleDbType enumerated value.

Remarks

Default = OracleDbType.Varchar2

If the OracleParameter object is used for Array Bind or PL/SQL Associative Array Bind execution, OracleDbType is the datatype of each element in the array.

The OracleDbType property and DbType property are linked. Therefore, setting the OracleDbType property changes the DbType property to a supporting DbType.

ParameterName

This property specifies the name of the parameter.

Declaration

// C#
public string ParameterName { get; set; }

Property Value

String

Implements

IDataParameter

Remarks

Default = null

Oracle supports ParameterName up to 30 characters.

Precision

This property specifies the maximum number of digits used to represent the Value property.

Declaration

// C#
Public byte Precision { get; set; }

Property Value

byte

Remarks

Default = 0

The Precision property is used by parameters of type OracleDbType.Decimal.

Oracle supports Precision range from 0 to 38.

For Array Bind and PL/SQL Associative Array Bind, Precision applies to each element in the Value property.

Scale

This property specifies the number of decimal places to which Value property is resolved.

Declaration

// C#
public byte Scale { get; set; }

Property Value

byte

Remarks

Default = 0.

Scale is used by parameters of type OracleDbType.Decimal.

Oracle supports Scale between -84 and 127.

For Array Bind and PL/SQL Associative Array Bind, Scale applies to each element in the Value property.

Size

This property specifies the maximum size, in bytes or characters, of the data transmitted to or from the database.

Declaration

// C#
public int Size { get; set;}

Property Value

int

Exceptions

ArgumentOutOfRangeException - The Size value specified is invalid.

InvalidOperationException - The Size = 0 when the OracleParameter object is used to bind a PL/SQL Associative Array.

Remarks

For PL/SQL Associative Array Bind, Size specifies the maximum number of elements in PL/SQL Associative Array.

If Size is not explicitly set, it is inferred from the actual size of the specified parameter value when binding only for input parameters. Output parameters must have their size defined explicitly.

The default value is 0.

Before execution, this property specifies the maximum size to be bound in the Value property. After execution, it contains the size of the type in the Value property.

Size is used for parameters of the following types:

  • OracleDbType.Blob

  • OracleDbType.Char

  • OracleDbType.Clob

  • OracleDbType.LongRaw

  • OracleDbType.NChar

  • OracleDbType.NClob

  • OracleDbType.NVarchar2

  • OracleDbType.Raw

  • OracleDbType.Varchar2

The value of Size is handled as follows:

  • Fixed length datatypes: ignored

  • Variable length datatypes: describes the maximum amount of data transmitted to or from the database. For character data, Size is in number of characters and for binary data, it is in number of bytes.

If the Size is not explicitly set, it is inferred from the actual size of the specified parameter value when binding.


Note:

Size does not include the null terminating character for the string data.

If the OracleParameter object is used to bind a PL/SQL Associative Array, Size specifies the maximum number of elements in the PL/SQL Associative Array. Before the execution, this property specifies the maximum number of elements in the PL/SQL Associative Array. After the execution, it specifies the current number of elements returned in the PL/SQL Associative Array. For Output and InputOutput parameters and return values, Size specifies the maximum number of elements in the PL/SQL Associative Array.

ODP.NET does not support binding an empty PL/SQL Associative Array. Therefore, Size cannot be set to 0 when the OracleParameter object is used to bind a PL/SQL Associative Array.

SourceColumn

This property specifies the name of the DataTable Column of the DataSet.

Declaration

// C#
public string SourceColumn { get; set; }

Property Value

A string.

Implements

IDataParameter

Remarks

Default = empty string

SourceVersion

This property specifies the DataRowVersion value to use when loading the Value property of the parameter.

Declaration

// C#
public DataRowVersion SourceVersion { get; set; }

Property Value

DataRowVersion

Implements

IDataParameter

Exceptions

ArgumentOutOfRangeException - The DataRowVersion value specified is invalid.

Remarks

Default = DataRowVersion.Current

SourceVersion is used by the OracleDataAdapter.UpdateCommand() during the OracleDataAdapter.Update to determine whether the original or current value is used for a parameter value. This allows primary keys to be updated. This property is ignored by the OracleDataAdapter.InsertCommand() and the OracleDataAdapter.DeleteCommand().

Status

This property indicates the status of the execution related to the data in the Value property.

Declaration

// C#
public OracleParameterStatus Status { get; set; }

Property Value

An OracleParameterStatus enumerated value.

Exceptions

ArgumentOutOfRangeException - The Status value specified is invalid.

Remarks

Default = OracleParameterStatus.Success

Before execution, this property indicates the bind status related to the Value property. After execution, it returns the status of the execution.

Status indicates if:

  • A NULL is fetched from a column.

  • Truncation has occurred during the fetch; then Value was not big enough to hold the data.

  • A NULL is to be inserted into a database column; then Value is ignored, and a NULL is inserted into a database column.

    This property is ignored for Array Bind and PL/SQL Associative Array Bind. Instead, ArrayBindStatus property is used.

Value

This property specifies the value of the Parameter.

Declaration

// C#
public object Value { get; set; }

Property Value

An object.

Implements

IDataParameter

Exceptions

ArgumentException - The Value property specified is invalid.

InvalidArgumentException- The Value property specified is invalid.

Remarks

Default = null

If the OracleParameter object is used for Array Bind or PL/SQL Associative Array, Value is an array of parameter values.

The Value property can be overwritten by OracleDataAdapter.Update().

The provider attempts to convert any type of value if it supports the IConvertible interface. Conversion errors occur if the specified type is not compatible with the value.

When sending a null parameter value to the database, the user must specify DBNull, not null. The null value in the system is an empty object that has no value. DBNull is used to represent null values. The user can also specify a null value by setting Status to OracleParameterStatus.NullValue. In this case, the provider sends a null value to the database.

If neither OracleDbType nor DbType are set, their values can be inferred by Value. Please see the following for related information:

For input parameters the value is:

  • Bound to the OracleCommand that is sent to the database.

  • Converted to the datatype specified in OracleDbType or DbType when the provider sends the data to the database.

For output parameters the value is:

  • Set on completion of the OracleCommand (true for return value parameters also).

  • Set to the data from the database, to the datatype specified in OracleDbType or DbType.

When array binding is used with:

  • Input parameter - Value should be set to an array of values. OracleCommand.ArrayBindCount should be set to a value that is greater than zero to indicate the number of elements to be bound.

    The number of elements in the array should be equal to the OracleCommand.ArrayBindCount property; otherwise, their minimum value is used to bind the elements in the array.

  • Output parameter - OracleCommand.ArrayBindCount should be set to a value that is greater than zero to indicate the number of elements to be retrieved (for SELECT statements).

When PL/SQL Associative Array binding is used with:

  • Input parameter – Value should be set to an array of values. CollectionType should be set to OracleCollection.PLSQLAssociativeArray.Size should be set to specify the possible maximum number of array elements in the PL/SQL Associative Array. If Size is smaller than the number of elements in Value, then Size specifies the number of elements in the Value property to be bound.

  • Output parameter - CollectionType should be set to OracleCollection.PLSQLAssociativeArray. Size should be set to specify the maximum number of array elements in PL/SQL Associative Array.

Each parameter should have a value. To bind a parameter with a null value, set Value to DBNull.Value, or set Status to OracleParameterStatus. NullInsert.


OracleParameter Public Methods

OracleParameter public methods are listed in Table 5-75.

Table 5-75 OracleParameter Public Methods

Public Method Description
Clone Creates a shallow copy of an OracleParameter object
CreateObjRef Inherited from MarshalByRefObject
Dispose Releases allocated resources
Equals Inherited from Object (Overloaded)
GetHashCode Inherited from Object
GetLifetimeService Inherited from MarshalByRefObject
GetType Inherited from Object
InitializeLifetimeService Inherited from MarshalByRefObject
ToString Inherited from Object (Overloaded)

Clone

This method creates a shallow copy of an OracleParameter object.

Declaration

// C#
public object Clone();

Return Value

An OracleParameter object.

Implements

ICloneable

Remarks

The cloned object has the same property values as that of the object being cloned.

Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client; 
 
class CloneSample
{
  static void Main()
  {  
    OracleN	Parameter prm1 = new OracleParameter();
 
    // Prints "prm1.ParameterName = "
    Console.WriteLine("prm1.ParameterName = " + prm1.ParameterName);
 
    // Set the ParameterName before cloning
    prm1.ParameterName = "MyParam";
 
    // Clone the OracleParameter
    OracleParameter prm2 = (OracleParameter) prm1.Clone();
 
    // Prints "prm2.ParameterName = MyParam"
    Console.WriteLine("prm2.ParameterName = " + prm2.ParameterName);
 
    prm1.Dispose();
    prm2.Dispose();
  }
}

Dispose

This method releases resources allocated for an OracleParameter object.

Declaration

// C#
public void Dispose();

Implements

IDisposable

PK EbNPKkUIOEBPS/oratypes.htm Z Oracle Data Provider for .NET Types Structures

11 Oracle Data Provider for .NET Types Structures

This chapter describes the ODP.NET Types structures.

This chapter contains these topics:

PKYۅy PKkUIOEBPS/OracleDateStructure.htm Oracle Data Provider for .NET Types Structures

OracleDate Structure

The OracleDate structure represents the Oracle DATE datatype to be stored in or retrieved from a database. Each OracleDate stores the following information: year, month, day, hour, minute, and second.

Class Inheritance

Object

  ValueType

    OracleDate

Declaration

// C#
public struct OracleDate : IComparable

Thread Safety

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

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
 
class OracleDateSample
{
  static void Main(string[] args)
  {
    // Initialize the dates to the lower and upper boundaries
    OracleDate date1 = OracleDate.MinValue;
    OracleDate date2 = OracleDate.MaxValue;
    OracleDate date3 = new OracleDate(DateTime.MinValue);
    OracleDate date4 = new OracleDate(DateTime.MaxValue);
    
    // Set the thread's DateFormat for output
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.DateFormat = "DD-MON-YYYY BC";
    OracleGlobalization.SetThreadInfo(info);
 
    // Print the lower and upper boundaries
    Console.WriteLine("OracleDate ranges from\n{0}\nto\n{1}\n", 
      date1, date2);
    Console.WriteLine(".NET DateTime ranges from\n{0}\nto\n{1}\n", 
      date3, date4);
  }
}

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll


OracleDate Members

OracleDate members are listed in the following tables:

OracleDate Constructors

OracleDate constructors are listed in Table 11-14

Table 11-14 OracleDate Constructors

Constructor Description
OracleDate Constructors Instantiates a new instance of OracleDate structure (Overloaded)

OracleDate Static Fields

The OracleDate static fields are listed in Table 11-15.

Table 11-15 OracleDate Static Fields

Field Description
MaxValue Represents the maximum valid date for an OracleDate structure, which is December 31, 9999 23:59:59
MinValue Represents the minimum valid date for an OracleDate structure, which is January 1, -4712 0:0:0
Null Represents a null value that can be assigned to the value of an OracleDate structure instance

OracleDate Static Methods

The OracleDate static methods are listed in Table 11-16.

Table 11-16 OracleDate Static Methods

Methods Description
Equals Determines if two OracleDate values are equal (Overloaded)
GreaterThan Determines if the first of two OracleDate values is greater than the second
GreaterThanOrEqual Determines if the first of two OracleDate values is greater than or equal to the second
LessThan Determines if the first of two OracleDate values is less than the second
LessThanOrEqual Determines if the first of two OracleDate values is less than or equal to the second
NotEquals Determines if two OracleDate values are not equal
GetSysDate Returns an OracleDate structure that represents the current date and time
Parse Returns an OracleDate structure and sets its value using a string

OracleDate Static Operators

The OracleDate static operators are listed in Table 11-17.

Table 11-17 OracleDate Static Operators

Operator Description
operator == Determines if two OracleDate values are the same
operator > Determines if the first of two OracleDate values is greater than the second
operator >= Determines if the first of two OracleDate values is greater than or equal to the second
operator != Determines if the two OracleDate values are not equal
operator < Determines if the first of two OracleDate values is less than the second
operator <= Determines if the first of two OracleDate values is less than or equal to the second

OracleDate Static Type Conversions

The OracleDate static type conversions are listed in Table 11-18.

Table 11-18 OracleDate Static Type Conversions

Operator Description
explicit operator DateTime Converts a structure to a DateTime structure
explicit operator OracleDate Converts a structure to an OracleDate structure (Overloaded)

OracleDate Properties

The OracleDate properties are listed in Table 11-19.

Table 11-19 OracleDate Properties

Properties Description
BinData Gets an array of bytes that represents an Oracle DATE in Oracle internal format
Day Gets the day component of an OracleDate method
IsNull Indicates whether or not the current instance has a null value
Hour Gets the hour component of an OracleDate
Minute Gets the minute component of an OracleDate
Month Gets the month component of an OracleDate
Second Gets the second component of an OracleDate
Value Gets the date and time that is stored in the OracleDate structure
Year Gets the year component of an OracleDate

OracleDate Methods

The OracleDate methods are listed in Table 11-20.

Table 11-20 OracleDate Methods

Methods Description
CompareTo Compares the current OracleDate instance to an object, and returns an integer that represents their relative values
Equals Determines whether or not an object has the same date and time as the current OracleDate instance (Overloaded)
GetHashCode Returns a hash code for the OracleDate instance
GetDaysBetween Calculates the number of days between the current OracleDate instance and an OracleDate structure
GetType Inherited from Object
ToOracleTimeStamp Converts the current OracleDate structure to an OracleTimeStamp structure
ToString Converts the current OracleDate structure to a string


OracleDate Constructors

The OracleDate constructors instantiates a new instance of the OracleDate structure.

Overload List:

  • OracleDate(DateTime)

    This constructor creates a new instance of the OracleDate structure and sets its value for date and time using the supplied DateTime value.

  • OracleDate(string)

    This constructor creates a new instance of the OracleDate structure and sets its value using the supplied string.

  • OracleDate(int, int, int)

    This constructor creates a new instance of the OracleDate structure and set its value for date using the supplied year, month, and day.

  • OracleDate(int, int, int, int, int, int)

    This constructor creates a new instance of the OracleDate structure and set its value for time using the supplied year, month, day, hour, minute, and second.

  • OracleDate(byte [ ])

    This constructor creates a new instance of the OracleDate structure and sets its value to the provided byte array, which is in the internal Oracle DATE format.

OracleDate(DateTime)

This constructor creates a new instance of the OracleDate structure and sets its value for date and time using the supplied DateTime value.

Declaration

// C#
public OracleDate (DateTime dt);

Parameters

  • dt

    The provided DateTime value.

Remarks

The OracleDate structure only supports up to a second precision. The time value in the provided DateTime structure that has a precision smaller than second is ignored.

OracleDate(string)

This constructor creates a new instance of the OracleDate structure and sets its value using the supplied string.

Declaration

// C#
public OracleDate (string dateStr);

Parameters

  • dateStr

    A string that represents an Oracle DATE.

Exceptions

ArgumentException - The dateStr is an invalid string representation of an Oracle DATE or the dateStr is not in the date format specified by the thread's OracleGlobalization.DateFormat property, which represents the Oracle NLS_DATE_FORMAT parameter.

ArgumentNullException - The dateStr is null.

Remarks

The names and abbreviations used for months and days are in the language specified by the DateLanguage and Calendar properties of the thread's OracleGlobalization object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
 
class OracleDateSample
{
  static void Main(string[] args)
  {
    // Set the thread's DateFormat for the OracleDate constructor
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.DateFormat = "YYYY-MON-DD";
    OracleGlobalization.SetThreadInfo(info);
    
    // construct OracleDate from a string using the DateFormat specified.
    OracleDate date = new OracleDate("1999-DEC-01");
    
    // Set a different DateFormat for the thread
    info.DateFormat = "MM/DD/YYYY";
    OracleGlobalization.SetThreadInfo(info);
 
    // Print "12/01/1999"
    Console.WriteLine(date.ToString()); 
  }
}

OracleDate(int, int, int)

This constructor creates a new instance of the OracleDate structure and set its value for date using the supplied year, month, and day.

Declaration

// C#
public OracleDate (int year, int month, int day);

Parameters

  • year

    The supplied year. Range of year is (-4712 to 9999).

  • month

    The supplied month. Range of month is (1 to 12).

  • day

    The supplied day. Range of day is (1 to 31).

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleDate (that is, the day is out of range for the month).

OracleDate(int, int, int, int, int, int)

This constructor creates a new instance of the OracleDate structure and set its value for time using the supplied year, month, day, hour, minute, and second.

Declaration

// C#
public OracleDate (int year, int month, int day, int hour, int minute, int second);

Parameters

  • year

    The supplied year. Range of year is (-4712 to 9999).

  • month

    The supplied month. Range of month is (1 to 12).

  • day

    The supplied day. Range of day is (1 to 31).

  • hour

    The supplied hour. Range of hour is (0 to 23).

  • minute

    The supplied minute. Range of minute is (0 to 59).

  • second

    The supplied second. Range of second is (0 to 59).

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleDate (that is, the day is out of range for the month).



OracleDate(byte [ ])

This constructor creates a new instance of the OracleDate structure and sets its value to the provided byte array, which is in the internal Oracle DATE format.

Declaration

// C#
public OracleDate(byte [] bytes);

Parameters

  • bytes

    A byte array that represents Oracle DATE in the internal Oracle DATE format.

Exceptions

ArgumentException - bytes is null or bytes is not in internal Oracle DATE format or bytes is not a valid Oracle DATE.


OracleDate Static Fields

The OracleDate static fields are listed in Table 11-21.

Table 11-21 OracleDate Static Fields

Field Description
MaxValue Represents the maximum valid date for an OracleDate structure, which is December 31, 9999 23:59:59
MinValue Represents the minimum valid date for an OracleDate structure, which is January 1, -4712 0:0:0
Null Represents a null value that can be assigned to the value of an OracleDate structure instance

MaxValue

This static field represents the maximum valid date for an OracleDate structure, which is December 31, 9999 23:59:59.

Declaration

// C#
public static readonly OracleDate MaxValue;

MinValue

This static field represents the minimum valid date for an OracleDate structure, which is January 1, -4712.

Declaration

// C#
public static readonly OracleDate MinValue;

Null

This static field represents a null value that can be assigned to the value of an OracleDate instance.

Declaration

// C#
public static readonly OracleDate Null;

OracleDate Static Methods

The OracleDate static methods are listed in Table 11-22.

Table 11-22 OracleDate Static Methods

Methods Description
Equals Determines if two OracleDate values are equal (Overloaded)
GreaterThan Determines if the first of two OracleDate values is greater than the second
GreaterThanOrEqual Determines if the first of two OracleDate values is greater than or equal to the second
LessThan Determines if the first of two OracleDate values is less than the second
LessThanOrEqual Determines if the first of two OracleDate values is less than or equal to the second
NotEquals Determines if two OracleDate values are not equal
GetSysDate Returns an OracleDate structure that represents the current date and time
Parse Returns an OracleDate structure and sets its value using a string

Equals

Overloads Object

This method determines if two OracleDate values are equal.

Declaration

// C#
public static bool Equals(OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if two OracleDate values are equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

GreaterThan

This method determines if the first of two OracleDate values is greater than the second.

Declaration

// C#
public static bool GreaterThan(OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is greater than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

GreaterThanOrEqual

This method determines if the first of two OracleDate values is greater than or equal to the second.

Declaration

// C#
public static bool GreaterThanOrEqual(OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

LessThan

This method determines if the first of two OracleDate values is less than the second.

Declaration

// C#
public static bool LessThan(OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is less than the second. Otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

LessThanOrEqual

This method determines if the first of two OracleDate values is less than or equal to the second.

Declaration

// C#
public static bool LessThanOrEqual(OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

NotEquals

This method determines if two OracleDate values are not equal.

Declaration

// C#
public static bool NotEquals(OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if two OracleDate values are not equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

GetSysDate

This method gets an OracleDate structure that represents the current date and time.

Declaration

// C#
public static OracleDate GetSysDate ();

Return Value

An OracleDate structure that represents the current date and time.

Parse

This method gets an OracleDate structure and sets its value for date and time using the supplied string.

Declaration

// C#
public static OracleDate Parse (string dateStr);

Parameters

  • dateStr

    A string that represents an Oracle DATE.

Return Value

An OracleDate structure.

Exceptions

ArgumentException - The dateStr is an invalid string representation of an Oracle DATE or the dateStr is not in the date format specified by the thread's OracleGlobalization.DateFormat property, which represents the Oracle NLS_DATE_FORMAT parameter.

ArgumentNullException - The dateStr is null.

Remarks

The names and abbreviations used for months and days are in the language specified by the DateLanguage and Calendar properties of the thread's OracleGlobalization object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
 
class ParseSample
{
  static void Main(string[] args)
  {
    // Set the thread's DateFormat for the OracleDate constructor
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.DateFormat = "YYYY-MON-DD";
    OracleGlobalization.SetThreadInfo(info);
    
    // Construct OracleDate from a string using the DateFormat specified
    OracleDate date = OracleDate.Parse("1999-DEC-01");
    
    // Set a different DateFormat on the thread for ToString() 
    info.DateFormat = "MM-DD-YY";
    OracleGlobalization.SetThreadInfo(info);
 
    // Print "12-01-1999"
    Console.WriteLine(date.ToString()); 
  }
}

OracleDate Static Operators

The OracleDate static operators are listed in Table 11-23.

Table 11-23 OracleDate Static Operators

Operator Description
operator == Determines if two OracleDate values are the same
operator > Determines if the first of two OracleDate values is greater than the second
operator >= Determines if the first of two OracleDate values is greater than or equal to the second
operator != Determines if the two OracleDate values are not equal
operator < Determines if the first of two OracleDate values is less than the second
operator <= Determines if the first of two OracleDate values is less than or equal to the second

operator ==

This method determines if two OracleDate values are the same.

Declaration

// C#
public static bool operator == (OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if they are the same; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

operator >

This method determines if the first of two OracleDate values is greater than the second.

Declaration

// C#
public static bool operator > (OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is greater than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

operator >=

This method determines if the first of two OracleDate values is greater than or equal to the second.

Declaration

// C#
public static bool operator >= (OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

operator !=

This method determines if the two OracleDate values are not equal.

Declaration

// C#
public static bool operator != (OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the two OracleDate values are not equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

operator <

This method determines if the first of two OracleDate values is less than the second.

Declaration

// C#
public static bool operator < (OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is less than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

operator <=

This method determines if the first of two OracleDate values is less than or equal to the second.

Declaration

// C#
public static bool operator <= (OracleDate value1, OracleDate value2);

Parameters

  • value1

    The first OracleDate.

  • value2

    The second OracleDate.

Return Value

Returns true if the first of two OracleDate values is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.


OracleDate Static Type Conversions

The OracleDate static type conversions are listed in Table 11-24.

Table 11-24 OracleDate Static Type Conversions

Operator Description
explicit operator DateTime Converts a structure to a DateTime structure
explicit operator OracleDate Converts a structure to an OracleDate structure (Overloaded)

explicit operator DateTime

This method converts an OracleDate structure to a DateTime structure.

Declaration

// C#
public static explicit operator DateTime(OracleDate val);

Parameters

  • val

    An OracleDate structure.

Return Value

A DateTime structure.

explicit operator OracleDate

explicit operator OracleDate converts the provided structure to an OracleDate structure.

Overload List:

explicit operator OracleDate(DateTime)

This method converts a DateTime structure to an OracleDate structure.

Declaration

// C#
public static explicit operator OracleDate(DateTime dt);

Parameters

  • dt

    A DateTime structure.

Return Value

An OracleDate structure.

explicit operator OracleDate(OracleTimeStamp)

This method converts an OracleTimeStamp structure to an OracleDate structure.

Declaration

// C#
public explicit operator OracleDate(OracleTimeStamp ts);

Parameters

  • ts

    OracleTimeStamp

Return Value

The returned OracleDate structure contains the date and time in the OracleTimeStamp structure.

Remarks

The precision of the OracleTimeStamp value can be lost during the conversion.

If the OracleTimeStamp structure has a null value, the returned OracleDate structure also has a null value.

explicit operator OracleDate(string)

This method converts the supplied string to an OracleDate structure.

Declaration

// C#
public explicit operator OracleDate (string dateStr);

Parameters

  • dateStr

    A string representation of an Oracle DATE.

Return Value

The returned OracleDate structure contains the date and time in the string dateStr.

Exceptions

ArgumentNullException - The dateStr is null.

ArgumentException - This exception is thrown if any of the following conditions exist:

  • The dateStr is an invalid string representation of an Oracle DATE.

  • The dateStr is not in the date format specified by the thread's OracleGlobalization.DateFormat property, which represents the Oracle NLS_DATE_FORMAT parameter.

Remarks

The names and abbreviations used for months and days are in the language specified by the DateLanguage and Calendar properties of the thread's OracleGlobalization object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class OracleDateSample
{
  static void Main(string[] args)
  {
    // Set the thread's DateFormat to a specific format
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.DateFormat = "YYYY-MON-DD";
    OracleGlobalization.SetThreadInfo(info);
    
    // Construct OracleDate from a string using the DateFormat specified
    OracleDate date = (OracleDate)"1999-DEC-01";
    
    // Set a different DateFormat on the thread for ToString() 
    info.DateFormat = "MON DD YY";
    OracleGlobalization.SetThreadInfo(info);
 
    // Prints "DEC 01 99"
    Console.WriteLine(date.ToString()); 
  }
}

OracleDate Properties

The OracleDate properties are listed in Table 11-25.

Table 11-25 OracleDate Properties

Properties Description
BinData Gets an array of bytes that represents an Oracle DATE in Oracle internal format
Day Gets the day component of an OracleDate method
IsNull Indicates whether or not the current instance has a null value
Hour Gets the hour component of an OracleDate
Minute Gets the minute component of an OracleDate
Month Gets the month component of an OracleDate
Second Gets the second component of an OracleDate
Value Gets the date and time that is stored in the OracleDate structure
Year Gets the year component of an OracleDate

BinData

This property gets a array of bytes that represents an Oracle DATE in Oracle internal format.

Declaration

// C#
public byte[] BinData{get;}

Property Value

An array of bytes.

Exceptions

OracleNullValueException - OracleDate has a null value.

Day

This property gets the day component of an OracleDate.

Declaration

// C#
public int Day{get;}

Property Value

A number that represents the day. Range of Day is (1 to 31).

Exceptions

OracleNullValueException - OracleDate has a null value.

IsNull

This property indicates whether or not the current instance has a null value.

Declaration

// C#
public bool IsNull{get;}

Property Value

Returns true if the current instance has a null value; otherwise, returns false.

Hour

This property gets the hour component of an OracleDate.

Declaration

// C#
public int Hour {get;}

Property Value

A number that represents Hour. Range of Hour is (0 to 23).

Exceptions

OracleNullValueException - OracleDate has a null value.

Minute

This property gets the minute component of an OracleDate.

Declaration

// C#
public int Minute {get;}

Property Value

A number that represents Minute. Range of Minute is (0 to 59).

Exceptions

OracleNullValueException - OracleDate has a null value.

Month

This property gets the month component of an OracleDate.

Declaration

// C#
public int Month {get;}

Property Value

A number that represents Month. Range of Month is (1 to 12).

Exceptions

OracleNullValueException - OracleDate has a null value.

Second

This property gets the second component of an OracleDate.

Declaration

// C#
public int Second {get;}

Property Value

A number that represents Second. Range of Second is (0 to 59).

Exceptions

OracleNullValueException - OracleDate has a null valuFte.

Value

This property specifies the date and time that is stored in the OracleDate structure.

Declaration

// C#
public DateTime Value {get;}

Property Value

A DateTime.

Exceptions

OracleNullValueException - OracleDate has a null value.

Year

This property gets the year component of an OracleDate.

Declaration

// C#
public int Year {get;}

Property Value

A number that represents Year. Range of Year is (-4712 to 9999).

Exceptions

OracleNullValueException - OracleDate has a null value.


OracleDate Methods

The OracleDate methods are listed in Table 11-26.

Table 11-26 OracleDate Methods

Methods Description
CompareTo Compares the current OracleDate instance to an object, and returns an integer that represents their relative values
Equals Determines whether or not an object has the same date and time as the current OracleDate instance (Overloaded)
GetHashCode Returns a hash code for the OracleDate instance
GetDaysBetween Calculates the number of days between the current OracleDate instance and an OracleDate structure
GetType Inherited from Object
ToOracleTimeStamp Converts the current OracleDate structure to an OracleTimeStamp structure
ToString Converts the current OracleDate structure to a string

CompareTo

This method compares the current OracleDate instance to an object, and returns an integer that represents their relative values.

Declaration

// C#
public int CompareTo(object obj);

Parameters

  • obj

    An object.

Return Value

The method returns:

  • Less than zero: if the current OracleDate instance value is less than that of obj.

  • Zero: if the current OracleDate instance and obj values are equal.

  • Greater than zero: if the current OracleDate instance value is greater than obj.

Implements

IComparable

Exceptions

ArgumentException - The obj parameter is not an instance of OracleDate.

Remarks

The following rules apply to the behavior of this method.

  • The comparison must be between OracleDates. For example, comparing an OracleDate instance with an OracleBinary instance is not allowed. When an OracleDate is compared with a different type, an ArgumentException is thrown.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

Equals

This method determines whether or not an object has the same date and time as the current OracleDate instance.

Declaration

// C#
public override bool Equals( object obj);

Parameters

  • obj

    An object.

Return Value

Returns true if obj has the same type as the current instance and represents the same date and time; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleDate that has a value compares greater than an OracleDate that has a null value.

  • Two OracleDates that contain a null value are equal.

GetHashCode

Overrides Object

This method returns a hash code for the OracleDate instance.

Declaration

// C#
public override int GetHashCode();

Return Value

A number that represents the hash code.

GetDaysBetween

This method calculates the number of days between the current OracleDate instance and the supplied OracleDate structure.

Declaration

// C#
public int GetDaysBetween (OracleDate val);

Parameters

  • val

    An OracleDate structure.

Return Value

The number of days between the current OracleDate instance and the OracleDate structure.

Exceptions

OracleNullValueException - The current instance or the supplied OracleDate structure has a null value.

ToOracleTimeStamp

This method converts the current OracleDate structure to an OracleTimeStamp structure.

Declaration

// C#
public OracleTimeStamp ToOracleTimeStamp();

Return Value

An OracleTimeStamp structure.

Remarks

The returned OracleTimeStamp structure has date and time in the current instance.

If the OracleDate instance has a null value, the returned OracleTimeStamp structure has a null value.

ToString

Overrides ValueType

This method converts the current OracleDate structure to a string.

Declaration

// C#
public override string ToString();

Return Value

A string.

Remarks

The returned value is a string representation of the OracleDate in the format specified by the thread's OracleGlobalization.DateFormat property. The names and abbreviations used for months and days are in the language specified by the thread's OracleGlobalization.DateLanguage and OracleGlobalization.Calendar properties. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class ToStringSample
{
  static void Main(string[] args)
  {
    // Set the thread's DateFormat to a specific format
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.DateFormat = "YYYY-MON-DD";
    OracleGlobalization.SetThreadInfo(info);
    
    // Construct OracleDate from a string using the DateFormat specified
    OracleDate date = (OracleDate)"1999-DEC-01";
    
    // Set a different DateFormat on the thread for ToString() 
    info.DateFormat = "YYYY/MM/DD";
    OracleGlobalization.SetThreadInfo(info);
 
    // Prints "1999/12/01"
    Console.WriteLine(date.ToString()); 
  }
}
PK83 PKkUI"OEBPS/OracleTypeExceptionClass.htmhf Oracle Data Provider for .NET Types Exceptions

OracleTypeException Class

The OracleTypeException is the base exception class for handling exceptions that occur in the ODP.NET Types classes.

Class Inheritance

Object

  Exception

    SystemException

      OracleTypeException

Declaration

// C#
public class OracleTypeException : SystemException

Thread Safety

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

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll


OracleTypeException Members

OracleTypeException members are listed in the following tables:

OracleTypeException Constructors

The OracleTypeException constructors are listed in Table 12-1.

Table 12-1 OracleTypeException Constructor

Constructor Description
OracleTypeException Constructors Creates a new instance of the OracleTypeException class (Overloaded)

OracleTypeException Static Methods

The OracleTypeException static methods are listed in Table 12-2.

Table 12-2 OracleTypeException Static Methods

Methods Description
Equals Inherited from Object (Overloaded)

OracleTypeException Properties

The OracleTypeException properties are listed in Table 12-3.

Table 12-3 OracleTypeException Properties

Properties Description
HelpLink Inherited from Exception
InnerException Inherited from Exception
Message
Specifies the error messages that occur in the exception
Source
Specifies the name of the data provider that generates the error
StackTrace Inherited from Exception
TargetSite Inherited from Exception

OracleTypeException Methods

The OracleTypeException methods are listed in Table 12-4.

Table 12-4 OracleTypeException Methods

Methods Description
Equals Inherited from Object (Overloaded)
GetBaseException Inherited from Exception
GetHashCode Inherited from Object
GetObjectData Inherited from Exception
GetType Inherited from Object
ToString
Returns the fully qualified name of this exception


OracleTypeException Constructors

The OracleTypeException constructors create new instances of the OracleTypeException class.

Overload List:

OracleTypeException(string)

This constructor creates a new instance of the OracleTypeException class with the specified error message, errMessage.

Declaration

// C#
public OracleTypeException (string errMessage); 

Parameters

  • errMessage

    The specified error message.

OracleTypeException(SerializationInfo, StreamingContext)

This constructor creates a new instance of the OracleTypeException class with the specified serialization information, si, and the specified streaming context, sc.

Declaration

// C#
protected OracleTypeException (SerializationInfo si, StreamingContext sc);

Parameters

  • si

    The specified serialization information.

  • sc

    The specified streaming context.


OracleTypeException Static Methods

The OracleTypeException static methods are listed in Table 12-5.

Table 12-5 OracleTypeException Static Methods

Methods Description
Equals Inherited from Object (Overloaded)


OracleTypeException Properties

The OracleTypeException properties are listed in Table 12-6.

Table 12-6 OracleTypeException Properties

Properties Description
HelpLink Inherited from Exception
InnerException Inherited from Exception
Message
Specifies the error messages that occur in the exception
Source
Specifies the name of the data provider that generates the error
StackTrace Inherited from Exception
TargetSite Inherited from Exception

Message

Overrides Exception

This property specifies the error messages that occur in the exception.

Declaration

// C#
public override string Message {get;}

Property Value

An error message.

Source

Overrides Exception

This property specifies the name of the data provider that generates the error.

Declaration

// C#
public override string Source {get;}

Property Value

Oracle Data Provider for .NET.


OracleTypeException Methods

The OracleTypeException methods are listed in Table 12-7.

Table 12-7 OracleTypeException Methods

Methods Description
Equals Inherited from Object (Overloaded)
GetBaseException Inherited from Exception
GetHashCode Inherited from Object
GetObjectData Inherited from Exception
GetType Inherited from Object
ToString
Returns the fully qualified name of this exception

ToString

Overrides Exception

This method returns the fully qualified name of this exception, the error message in the Message property, the InnerException.ToString() message, and the stack trace.

Declaration

// C#
public override string ToString();

Return Value

The fully qualified name of this exception.

PKTmfhfPKkUIOEBPS/OracleBinaryStructure.htm Oracle Data Provider for .NET Types Structures

OracleBinary Structure

The OracleBinary structure represents a variable-length stream of binary data to be stored in or retrieved from a database.

Class Inheritance

Object

  ValueType

    OracleBinary

Declaration

// C#
public struct OracleBinary : IComparable

Thread Safety

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

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class OracleBinarySample
{
  static void Main(string[] args)
  {
    // Initialize the OracleBinary structures
    OracleBinary binary1= new OracleBinary(new byte[] {1,2,3,4,5});
    OracleBinary binary2 = new OracleBinary(new byte[] {1,2,3});
    OracleBinary binary3 = new OracleBinary(new byte[] {4,5});
    OracleBinary binary4 = binary2 + binary3;
    
    // Compare binary1 and binary4; they're equal
    if (binary1 == binary4)
      Console.WriteLine("The two OracleBinary structs are equal");
    else
      Console.WriteLine("The two OracleBinary structs are different");
  }
}

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll


OracleBinary Members

OracleBinary members are listed in the following tables:

OracleBinary Constructors

OracleBinary constructors are listed in Table 11-1

Table 11-1 OracleBinary Constructors

Constructor Description
OracleBinary Constructor Instantiates a new instance of OracleBinary structure

OracleBinary Static Fields

The OracleBinary static fields are listed in Table 11-2.

Table 11-2 OracleBinary Static Fields

Field Description
Null Represents a null value that can be assigned to an instance of the OracleBinary structure

OracleBinary Static Methods

The OracleBinary static methods are listed in Table 11-3.

Table 11-3 OracleBinary Static Methods

Methods Description
Concat Returns the concatenation of two OracleBinary structures
Equals Determines if two OracleBinary values are equal (Overloaded)
GreaterThan Determines if the first of two OracleBinary values is greater than the second
GreaterThanOrEqual Determines if the first of two OracleBinary values is greater than or equal to the second
LessThan Determines if the first of two OracleBinary values is less than the second
LessThanOrEqual Determines if the first of two OracleBinary values is less than or equal to the second
NotEquals Determines if two OracleBinary values are not equal

OracleBinary Static Operators

The OracleBinary static operators are listed in Table 11-4.

Table 11-4 OracleBinary Static Operators

Operator Description
operator + Concatenates two OracleBinary values
operator == Determines if two OracleBinary values are equal
operator > Determines if the first of two OracleBinary values is greater than the second
operator >= Determines if the first of two OracleBinary values is greater than or equal to the second
operator != Determines if two OracleBinary values are not equal
operator < Determines if the first of two OracleBinary value is less than the second
operator <= Determines if the first of two OracleBinary value is less than or equal to the second

OracleBinary Static Type Conversion Operators

The OracleBinary static type conversion operators are listed in Table 11-5.

Table 11-5 OracleBinary Static Type Conversion Operators

Operator Description
explicit operator byte[ ] Converts an instance value to a byte array
implicit operator OracleBinary Converts an instance value to an OracleBinary structure

OracleBinary Properties

The OracleBinary properties are listed in Table 11-6.

Table 11-6 OracleBinary Properties

Properties Description
IsNull Indicates whether or not the current instance has a null value
Item Obtains the particular byte in an OracleBinary structure using an index
Length Returns the length of the binary data
Value Returns the binary data that is stored in an OracleBinary structure

OracleBinary Instance Methods

The OracleBinary instance methods are listed in Table 11-7.

Table 11-7 OracleBinary Instance Methods

Methods Description
CompareTo Compares the current instance to an object and returns an integer that represents their relative values
Equals Determines if two objects contain the same binary data (Overloaded)
GetHashCode Returns a hash code for the current instance
GetType Inherited from Object
ToString Converts the current OracleBinary structure to a string


OracleBinary Constructor

The OracleBinary constructor instantiates a new instance of the OracleBinary structure and sets its value to the provided array of bytes.

Declaration

// C#
public OracleBinary(byte[ ] bytes); 

Parameters

  • bytes

    A byte array.


OracleBinary Static Fields

The OracleBinary static fields are listed in Table 11-8.

Table 11-8 OracleBinary Static Fields

Field Description
Null Represents a null value that can be assigned to an instance of the OracleBinary structure

Null

This static field represents a null value that can be assigned to an instance of the OracleBinary structure.

Declaration

// C#
public static readonly OracleBinary Null;

OracleBinary Static Methods

The OracleBinary static methods are listed in Table 11-9.

Table 11-9 OracleBinary Static Methods

Methods Description
Concat Returns the concatenation of two OracleBinary structures
Equals Determines if two OracleBinary values are equal (Overloaded)
GreaterThan Determines if the first of two OracleBinary values is greater than the second
GreaterThanOrEqual Determines if the first of two OracleBinary values is greater than or equal to the second
LessThan Determines if the first of two OracleBinary values is less than the second
LessThanOrEqual Determines if the first of two OracleBinary values is less than or equal to the second
NotEquals Determines if two OracleBinary values are not equal

Concat

This method returns the concatenation of two OracleBinary structures.

Declaration

// C#
public static OracleBinary Concat(OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

An OracleBinary.

Remarks

If either argument has a null value, the returned OracleBinary structure has a null value.

Equals

This method determines if two OracleBinary values are equal.

Declaration

// C#
public static bool Equals(OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if two OracleBinary values are equal; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

GreaterThan

This method determines whether or not the first of two OracleBinary values is greater than the second.

Declaration

// C#
public static bool GreaterThan(OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is greater than the second; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class GreaterThanSample
{
  static void Main(string[] args)
  {
    OracleBinary binary1 = OracleBinary.Null;
    OracleBinary binary2 = new OracleBinary(new byte[] {1});
 
    // Compare two OracleBinary structs; binary1 < binary2
    if (OracleBinary.GreaterThan(binary1, binary2))
      Console.WriteLine("binary1 > binary2");
    else
      Console.WriteLine("binary1 < binary2");
  }
}

GreaterThanOrEqual

This method determines whether or not the first of two OracleBinary values is greater than or equal to the second.

Declaration

// C#
public static bool GreaterThanOrEqual(OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is greater than or equal to the second; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value. </p>

  • Two OracleBinarys that contain a null value are equal.

LessThan

This method determines whether or not the first of two OracleBinary values is less than the second.

Declaration

// C#
public static bool LessThan(OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is less than the second; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

LessThanOrEqual

This method determines whether or not the first of two OracleBinary values is less than or equal to the second.

Declaration

// C#
public static bool LessThanOrEqual(OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is less than or equal to the second; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

NotEquals

This method determines whether or not two OracleBinary values are not equal.

Declaration

// C#
public static bool NotEquals(OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if two OracleBinary values are not equal; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.


OracleBinary Static Operators

The OracleBinary static operators are listed in Table 11-10.

Table 11-10 OracleBinary Static Operators

Operator Description
operator + Concatenates two OracleBinary values
operator == Determines if two OracleBinary values are equal
operator > Determines if the first of two OracleBinary values is greater than the second
operator >= Determines if the first of two OracleBinary values is greater than or equal to the second
operator != Determines if two OracleBinary values are not equal
operator < Determines if the first of two OracleBinary value is less than the second
operator <= Determines if the first of two OracleBinary value is less than or equal to the second

operator +

This method concatenates two OracleBinary values.

Declaration

// C#
public static OracleBinary operator + (OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

OracleBinary

Remarks

If either argument has a null value, the returned OacleBinary structure has a null value.

operator ==

This method determines if two OracleBinary values are equal.

Declaration

// C#
public static bool operator == (OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if they are the same; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

operator >

This method determines if the first of two OracleBinary values is greater than the second.

Declaration

// C#
public static bool operator > (OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is greater than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class OperatorSample
{
  static void Main(string[] args)
  {
    OracleBinary binary1 = OracleBinary.Null;
    OracleBinary binary2 = new OracleBinary(new byte[] {1});
 
    // Compare two OracleBinary structs; binary1 < binary2
    if (binary1 > binary2)
      Console.WriteLine("binary1 > binary2");
    else
      Console.WriteLine("binary1 < binary2");
  }
}

operator >=

This method determines if the first of two OracleBinary values is greater than or equal to the second.

Declaration

// C#
public static bool operator >= (OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

operator !=

This method determines if two OracleBinary values are not equal.

Declaration

// C#
public static bool operator != (OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the two OracleBinary values are not equal; otherwise, returns false.

operator <

This method determines if the first of two OracleBinary values is less than the second.

Declaration

// C#
public static bool operator < ( OracleBinary value1, OracleBinary value2);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is less than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

operator <=

This method determines if the first of two OracleBinary values is less than or equal to the second.

Declaration

// C#
public static bool operator <= (OracleBinary value1, OracleBinary value1);

Parameters

  • value1

    The first OracleBinary.

  • value2

    The second OracleBinary.

Return Value

Returns true if the first of two OracleBinary values is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.


OracleBinary Static Type Conversion Operators

The OracleBinary static type conversion operators are listed in Table 11-11.

Table 11-11 OracleBinary Static Type Conversion Operators

Operator Description
explicit operator byte[ ] Converts an instance value to a byte array
implicit operator OracleBinary Converts an instance value to an OracleBinary structure

explicit operator byte[ ]

This method converts an OracleBinary value to a byte array.

Declaration

// C#
public static explicit operator byte[ ] (OracleBinary val);

Parameters

  • val

    An OracleBinary.

Return Value

A byte array.

Exceptions

OracleNullValueException - The OracleBinary structure has a null value.

implicit operator OracleBinary

This method converts a byte array to an OracleBinary structure.

Declaration

// C#
public static implicit operator OracleBinary(byte[ ] bytes);

Parameters

  • bytes

    A byte array.

Return Value

OracleBinary


OracleBinary Properties

The OracleBinary properties are listed in Table 11-12.

Table 11-12 OracleBinary Properties

Properties Description
IsNull Indicates whether or not the current instance has a null value
Item Obtains the particular byte in an OracleBinary structure using an index
Length Returns the length of the binary data
Value Returns the binary data that is stored in an OracleBinary structure

IsNull

This property indicates whether or not the current instance has a null value.

Declaration

// C#
public bool IsNull {get;}

Property Value

Returns true if the current instance has a null value; otherwise returns false.

Item

This property obtains the particular byte in an OracleBinary structure using an index.

Declaration

// C#
pub8lic byte this[int index] {get;}

Property Value

A byte in the specified index.

Exceptions

OracleNullValueException - The current instance has a null value.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class ItemSample
{
  static void Main(string[] args)
  {
    OracleBinary binary = new OracleBinary(new byte[] {1,2,3,4});
 
    // Prints the value 4
    Console.WriteLine(binary[binary.Length - 1]); 
  }
}

Length

This property returns the length of the binary data.

Declaration

// C#
public int length {get;}

Property Value

Length of the binary data.

Exceptions

OracleNullValueException - The current instance has a null value.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class LengthSample
{
  static void Main(string[] args)
  {
    OracleBinary binary = new OracleBinary(new byte[] {1,2,3,4});
 
    // Prints the value 4
    Console.WriteLine(binary.Length);
  }
}

Value

This property returns the binary data that is stored in the OracleBinary structure.

Declaration

// C#
public byte[] Value {get;}

Property Value

Binary data.

Exceptions

OracleNullValueException - The current instance has a null value.


OracleBinary Instance Methods

The OracleBinary instance methods are listed in Table 11-13.

Table 11-13 OracleBinary Instance Methods

Methods Description
CompareTo Compares the current instance to an object and returns an integer that represents their relative values
Equals Determines if two objects contain the same binary data (Overloaded)
GetHashCode Returns a hash code for the current instance
GetType Inherited from Object
ToString Converts the current OracleBinary structure to a string

CompareTo

This method compares the current instance to an object and returns an integer that represents their relative values

Declaration

// C#
public int CompareTo(object obj);

Parameters

  • obj

    The object being compared.

Return Value

The method returns a number that is:

  • Less than zero: if the current OracleBinary instance value is less than obj.

  • Zero: if the current OracleBinary instance and obj values have the same binary data.

  • Greater than zero: if the current OracleBinary instance value is greater than obj.

Implements

IComparable

Exceptions

ArgumentException - The parameter is not of type OracleBinary.

Remarks

The following rules apply to the behavior of this method.

  • The comparison must be between OracleBinarys. For example, comparing an OracleBinary instance with an OracleTimeStamp instance is not allowed. When an OracleBinary is compared with a different type, an ArgumentException is thrown.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class CompareToSample
{
  static void Main(string[] args)
  {
    OracleBinary binary1 = new OracleBinary(new byte[] {1,2,3});
    OracleBinary binary2 = new OracleBinary(new byte[] {1,2,3,4});
    
    // Compare
    if (binary1.CompareTo(binary2) == 0)
      Console.WriteLine("binary1 is the same as binary2");
    else
      Console.WriteLine("binary1 is different from binary2");      
  }
}

Equals

This method determines whether or not an object is an instance of OracleBinary, and has the same binary data as the current instance.

Declaration

// C#
public override bool Equals(object obj);

Parameters

  • obj

    The object being compared.

Return Value

Returns true if obj is an instance of OracleBinary, and has the same binary data as the current instance; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleBinary that has a value is greater than an OracleBinary that has a null value.

  • Two OracleBinarys that contain a null value are equal.

GetHashCode

Overrides Object

This method returns a hash code for the OracleBinary instance.

Declaration

// C#
public override int GetHashCode();

Return Value

An int that represents the hash.

ToString

Overrides Object

This method converts an OracleBinary instance to a string instance.

Declaration

// C#
public override string ToString();

Return Value

string

Remarks

If the current OracleBinary instance has a null value, the returned string "null".

PK%.q988PKkUIOEBPS/featSafeType.htm?d Features of Oracle Data Provider for .NET

OracleDataAdapter Safe Type Mapping

The ODP.NET OracleDataAdapter class provides the Safe Type Mapping feature to ensure that the following Oracle datatypes do not lose data when converted to their closely related .NET types in the DataSet:

  • NUMBER

  • DATE

  • TimeStamp (refers to all TimeStamp objects)

  • INTERVAL DAY TO SECOND

This section includes the following topics:

Comparison Between Oracle Datatypes and .NET Types

The following sections provide more details about the differences between the Oracle datatypes and the corresponding .NET types. In general, the Oracle datatypes allow a greater degree of precision than the .NET types do.

Oracle NUMBER Type to .NET Decimal Type

The Oracle datatype NUMBER can hold up to 38 precision, and the .NET Decimal type can hold up to 28 precision. If a NUMBER datatype that has more than 28 precision is retrieved into a .NET Decimal type, it loses precision.

Table 3-17 lists the maximum and minimum values for Oracle NUMBER and .NET Decimal types.

Table 3-17 Oracle NUMBER to .NET Decimal Comparisons

Value Limits Oracle NUMBER .NET Decimal
Maximum 9.9999999999999999999999999999999999999 e125 79,228,162,514,264,337,593,543,950,335
Minimum -9.9999999999999999999999999999999999999 e125 -79,228,162,514,264,337,593,543,950,335

Oracle Date Type to .NET DateTime Type

The Oracle datatype DATE can represent dates in BC whereas the .NET DateTime type cannot. If a DATE that goes to BC get retrieved into a .NET DateTime type, it loses data.

Table 3-18 lists the maximum and minimum values for Oracle Date and .NET DateTime types.

Table 3-18 Oracle Date to .NET DateTime Comparisons

Value Limits Oracle Date .NET DateTime
Maximum Dec 31, 9999 AD Dec 31, 9999 AD 23:59:59.9999999
Minimum Jan 1, 4712 BC Jan 1, 0001 AD 00:00:00.0000000

Oracle TimeStamp Type to .NET DateTime Type

Similar to the DATE datatype, the Oracle TimeStamp datatype can represent a date in BC, and a .NET DateTime type cannot. If a TimeStamp that goes to BC is retrieved into a.NET DateTime type, it loses data. The Oracle TimeStamp type can represent values in units of e-9; the .NET DateTime type can represent only values in units of e-7. The Oracle TimeStamp with time zone datatype can store time zone information, and the .NET DateTime type cannot.

Table 3-19 lists the maximum and minimum values for Oracle TimeStamp and .NET DateTime types.

Table 3-19 Oracle TimeStamp to .NET DateTime Comparisons

Value Limits Oracle TimeStamp .NET DateTime
Maximum Dec 31, 9999 AD 23:59:59.999999999 Dec 31, 9999 AD 23:59:59.9999999
Minimum Jan 1, 4712 BC 00:00:00.000000000 Jan 1, 0001 AD 00:00:00.0000000

Oracle INTERVAL DAY TO SECOND to .NET TimeSpan

The Oracle datatype INTERVAL DAY TO SECOND can hold up to 9 precision, and the .NET TimeSpan type can hold up to 7 precision. If an INTERVAL DAY TO SECOND datatype that has more than 7 precision is retrieved into a .NET TimeSpan type, it loses precision. The Oracle INTERVAL DAY TO SECOND type can represent values in units of e-9, and the .NET TimeSpan type can represent only values in units of e-7.

Table 3-20 lists the maximum and minimum values for Oracle INTERVAL DAY TO SECOND and .NET DateTime types.

Table 3-20 Oracle INTERVAL DAY TO SECOND to .NET TimeSpan Comparisons

Value Limits Oracle INTERVAL DAY TO SECOND .NET TmeSpan
Maximum +999999999 23:59:59.999999999 +10675199 02:48:05.4775807
Minimum -999999999 23:59:59.999999999 -10675199 02:48:05.4775808

SafeMapping Property

The OracleDataAdapter Safe Type Mapping feature prevents data loss when populating Oracle data for any of these types into a .NET DataSet. By setting the SafeMapping property appropriately, these types can be safely represented in the DataSet, as either of the following:

  • .NET byte[] in Oracle format

  • .NET String

By default, Safe Type Mapping is disabled.

Using Safe Type Mapping

To use the Safe Type Mapping feature, the OracleDataAdapter.SafeMapping property must be set with a hash table of key-value pairs. The key-value pairs must map database table column names (of type string) to a .NET type (of type Type). ODP.NET supports Safe Type Mapping to byte[] and String types. Any other type mapping causes an exception.

In situations where the column names are not known at design time, an asterisk ("*") can be used to map all occurrences of database types to a safe .NET type. If both the valid column name and the asterisk are present, the column name is used.


Note:

  • Database table column names are case-sensitive.

  • Column names in the hash table that correspond to invalid column names are ignored.


Safe Type Mapping as a string is more readable without further conversion. Converting certain Oracle datatypes to a string requires extra conversion, which can be slower than converting it to a byte[]. Conversion of .NET strings back to ODP.NET types relies on the formatting information of the session.

SafeTyping Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client; 
 
class SafeMappingSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
 
    // In this SELECT statement, EMPNO, HIREDATE and SALARY must be
    // preserved using safe type mapping.
    string cmdstr = "SELECT EMPNO, ENAME, HIREDATE, SAL FROM EMP";
 
    // Create the adapter with the selectCommand txt and the connection string
    OracleDataAdapter adapter = new OracleDataAdapter(cmdstr, constr);
 
    // Get the connection from the adapter
    OracleConnection connection = adapter.SelectCommand.Connection;
 
    // Create the safe type mapping for the adapter
    // which can safely map column data to byte arrays, where
    // applicable. By executing the following statement, EMPNO, HIREDATE AND
    // SALARY columns will be mapped to byte[]
    adapter.SafeMapping.Add("*", typeof(byte[]));
 
    // Map HIREDATE to a string
    // If the column name in the EMP table is case-sensitive,
    // the safe type mapping column name must be case-sensitive.
    adapter.SafeMapping.Add("HIREDATE", typeof(string));
 
    // Map EMPNO to a string
    // If the column name in the EMP table is case-sensitive,
    // the safe type mapping column name must also be case-sensitive.
    adapter.SafeMapping.Add("EMPNO", typeof(string));
    adapter.SafeMapping.Add("SAL", typeof(string));
 
    // Create and fill the DataSet using the EMP
    DataSet dataset = new DataSet();
    adapter.Fill(dataset, "EMP");
 
    // Get the EMP table from the dataset
    DataTable table = dataset.Tables["EMP"];
 
    // Get the first row from the EMP table
    DataRow row = table.Rows[0];
 
    // Print out the row info
    Console.WriteLine("EMPNO Column: type = " + row["EMPNO"].GetType() +
      "; value = " + row["EMPNO"]);
    Console.WriteLine("ENAME Column: type = " + row["ENAME"].GetType() +
      "; value = " + row["ENAME"]);
    Console.WriteLine("HIREDATE Column: type = " + row["HIREDATE"].GetType()+
      "; value = " + row["HIREDATE"]);
    Console.WriteLine("SAL Column: type = " + row["SAL"].GetType() +
      "; value = " + row["SAL"]);
  }
}

See Also:

"SafeMapping"

PKֺk??PKkUIOEBPS/whatsnew.htm$Eۺ What's New in Oracle Data Provider for .NET?

What's New in Oracle Data Provider for .NET?

This section describes new features in Oracle Data Provider for .NET 10g Release 2 (10.2) and provides references to additional information. New features information from previous releases is also retained to help those users migrating to the current release.

The following sections describe the new features in Oracle Data Provider for .NET:

New Features in Oracle Data Provider for .NET Release 10.2

Oracle Data Provider for .NET release 10.2 includes the following:

New Features in Oracle Data Provider for .NET Release 10.1.0.3

Oracle Data Provider for .NET release 10.1.0.3 includes the following:

New Features in Oracle Data Provider for .NET Release 10.1

Oracle Data Provider for .NET release 10.1 includes the following:

New Features in Oracle Data Provider for .NET Release 9.2.0.4

Oracle Data Provider for .NET release 9.2.0.4, which was released on Oracle Technology Network (OTN), included the following:

PKؖp)E$EPKkUIOEBPS/featRefCursor.htmx7 Features of Oracle Data Provider for .NET

PL/SQL REF CURSOR and OracleRefCursor

The REF CURSOR is a datatype in the Oracle PL/SQL language. It represents a cursor or a result set in Oracle Database. The OracleRefCursor object is a corresponding ODP.NET type for the REF CURSOR type.

This section discusses the following aspects of using the REF CURSOR datatype and OracleRefCursor objects:

Obtaining an OracleRefCursor Object

There are no constructors for OracleRefCursor objects. They can be acquired only as parameter values from PL/SQL stored procedures, stored functions, or anonymous blocks.

An OracleRefCursor object is a connected object. The connection used to execute the command returning an OracleRefCursor object is required for its lifetime. Once the connection associated with an OracleRefCursor object is closed, the OracleRefCursor object cannot be used.

Obtaining a REF CURSOR Datatype

A REF CURSOR datatype can be obtained as an OracleDataReader, DataSet, or OracleRefCursor object. If the REF CURSOR datatype is obtained as an OracleRefCursor object, it can be used to create an OracleDataReader object or populate a DataSet from it. When accessing a REF CURSOR datatype, always bind it as an OracleDbType.RefCursor parameter.

Populating an OracleDataReader from a REF CURSOR

A REF CURSOR datatype can be obtained as an OracleDataReader object by calling the ExecuteReader method of the OracleCommand object. The output parameter with the OracleDbType property set is bound to OracleDbType.RefCursor. None of the output parameters of type OracleDbType.RefCursor is populated after the ExecuteReader method is invoked.

If there are multiple output REF CURSOR parameters, use the NextResult method of the OracleDataReader object to access the next REF CURSOR datatype. The OracleDataReader NextResult method provides sequential access to the REF CURSOR datatypes; only one REF CURSOR datatype can be accessed at a given time.

The order in which OracleDataReader objects are created for the corresponding REF CURSOR datatypes depends on the order in which the parameters are bound. If a PL/SQL stored function returns a REF CURSOR datatype, then it becomes the first OracleDataReader object and all the output REF CURSOR datatypes follow the order in which the parameters are bound.

Populating the DataSet from a REF CURSOR

For the Fill method to populate the DataSet properly, the SelectCommand property of the OracleDataAdapter class must be bound with an output parameter of type OracleDbType.RefCursor. If the Fill method is successful, the DataSet is populated with a DataTable that represents a REF CURSOR datatype.

If the command execution returns multiple REF CURSOR datatypes, the DataSet is populated with multiple DataTable objects.

Populating an OracleRefCursor from a REF CURSOR

When the ExecuteNonQuery method is invoked on a command that returns one or more REF CURSOR datatypes, each of the OracleCommand parameters that are bound as an OracleDbType.RefCursor gets a reference to an OracleRefCursor object.

To create an OracleDataReader object from an OracleRefCursor object, invoke the GetDataReader method from the OracleRefCursor object. Subsequent calls to the GetDataReader method return a reference to the same OracleDataReader object.

To populate a DataSet with an OracleRefCursor object, the application can invoke a Fill method of the OracleDataAdapter class that takes an OracleRefCursor object. Similar to the OracleDataReader object, an OracleRefCursor object is forward-only. Therefore, once a row is read from an OracleRefCursor object, that same row cannot be obtained again from it unless it is populated again from a query.

When multiple REF CURSOR datatypes are returned from a command execution as OracleRefCursor objects, the application can choose to create an OracleDataReader object or populate a DataSet with a particular OracleRefCursor object. All the OracleDataReader objects or DataSet objects created from the OracleRefCursor objects are active at the same time, and can be accessed in any order.

Updating a DataSet Obtained from a REF CURSOR

REF CURSOR types cannot be updated. However, data that is retrieved into a DataSet can be updated. Therefore, the OracleDataAdapter class requires a custom SQL statement to flush any REF CURSOR data updates to the database.

The OracleCommandBuilder object cannot be used to generate SQL statements for REF CURSOR updates.

Behavior of ExecuteScalar Method for REF CURSOR

The ExecuteScalar method returns the value of the first column of the first row of the REF CURSOR if it is one of the following:

  • A return value of a stored function execution

  • The first bind parameter of a stored procedure execution

Passing a REF CURSOR to a Stored Procedure

An application can retrieve a REF CURSOR type from a PL/SQL stored procedure or function and pass it to another stored procedure or function. This feature is useful in scenarios where a stored procedure or a function returns a REF CURSOR type to the .NET application, and based on the application logic, the application passes this REF CURSOR to another stored procedure for processing. Note that if you retrieve the data from a REF CURSOR type in the .NET application, you cannot pass it back to another stored procedure.

The following example demonstrate passing a REF CURSOR:

/*
connect scott/tiger@oracle
create table test (col1 number);
insert into test(col1) values (1);
commit;
 
create or replace package testPkg as type empCur is REF Cursor;
end testPkg;
/
 
create or replace procedure testSP(param1 IN testPkg.empCur, param2 OUT NUMBER)
as
begin
FETCH param1 into param2;
end;
/
*/
 
// C#
 
 
using System;
using Oracle.DataAccess.Client;
using System.Data;
 
class InRefCursorParameterSample
{
  static void Main()
  {
    OracleConnection conn = new OracleConnection
      ("User Id=scott; Password=tiger; Data Source=oracle");
 
    conn.Open(); // Open the connection to the database
 
    // Command text for getting the REF Cursor as OUT parameter
    String cmdTxt1 = "begin open :1 for select col1 from test; end;";
 
    // Command text to pass the REF Cursor as IN parameter
    String cmdTxt2 = "begin testSP (:1, :2); end;";
 
    // Create the command object for executing cmdTxt1 and cmdTxt2
    OracleCommand cmd = new OracleCommand(cmdTxt1, conn);
 
    // Bind the Ref cursor to the PL/SQL stored procedure
    OracleParameter outRefPrm = cmd.Parameters.Add("outRefPrm",
      OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);
 
    cmd.ExecuteNonQuery(); // Execute the anonymous PL/SQL block
 
    // Reset the command object to execute another anonymous PL/SQL block
    cmd.Parameters.Clear();
    cmd.CommandText = cmdTxt2;
 
    // REF Cursor obtained from previous execution is passed to this 
    // procedure as IN parameter
    OracleParameter inRefPrm = cmd.Parameters.Add("inRefPrm",
      OracleDbType.RefCursor, outRefPrm.Value, ParameterDirection.Input);
 
    // Bind another Number parameter to get the REF Cursor column value
    OracleParameter outNumPrm = cmd.Parameters.Add("outNumPrm",
      OracleDbType.Int32, DBNull.Value, ParameterDirection.Output);
 
    cmd.ExecuteNonQuery(); //Execute the stored procedure
 
    // Display the out parameter value
    Console.WriteLine("out parameter is: " + outNumPrm.Value.ToString());
  }
}
PKW?}7x7PKkUIOEBPS/intro003.htmIm Introducing Oracle Data Provider for .NET

Oracle Data Provider for .NET Assembly

The Oracle.DataAccess.dll assembly provides two namespaces:

  • The Oracle.DataAccess.Client namespace contains ODP.NET classes and enumerations for the client-side provider.

  • The Oracle.DataAccess.Types namespace contains the Oracle Data Provider for .NET datatypes (ODP.NET Types).

Oracle.DataAccess.Client Namespace

The Oracle.DataAccess.Client namespace contains implementations of core ADO.NET classes and enumerations for ODP.NET, as well as ODP.NET specific classes.

The following tables list ODP.NET classes, enumerations, and types that are supported by the Oracle.DataAccess.Client namespace. The tables also indicated which classes are not supported in .NET stored procedures.

Oracle.DataAccess.Client

Table 1-1 lists the client classes.

Table 1-1 Oracle.DataAccess.Client

Class Description
OnChangeEventHandler Delegate
The OnChangedEventHandler event delegate represents the signature of the method that handles the notification.

Not Supported in a .NET Stored Procedure

OracleCommand Class
An OracleCommand object represents a SQL command, a stored procedure or function, or a table name.
OracleCommandBuilder Class
An OracleCommandBuilder object provides automatic SQL generation for the OracleDataAdapter when the database is updated.
OracleConnection Class
An OracleConnection object represents a connection to Oracle Database.
OracleDataAdapter Class
An OracleDataAdapter object represents a data provider object that communicates with the DataSet.
OracleDataReader Class
An OracleDataReader object represents a forward-only, read-only, in-memory result set.
OracleDependency Class
An OracleDependency class represents a dependency between an application and an Oracle database.

Not Supported in a .NET Stored Procedure

OracleError Class
The OracleError object represents an error reported by an Oracle database.
OracleErrorCollection Class
An OracleErrorCollection object represents a collection of OracleErrors.
OracleException Class
The OracleException object represents an exception that is thrown when Oracle Data Provider for .NET encounters an error.
OracleFailoverEventArgs Class
The OracleFailoverEventArgs class provides event data for the OracleConnection.Failover event.

Not Supported in a .NET Stored Procedure

OracleFailoverEventHandler Delegate
The OracleFailoverEventHandler represents the signature of the method that handles the OracleConnection.Failover event.

Not Supported in a .NET Stored Procedure

OracleGlobalization Class
The OracleGlobalization class is used to obtain and set the Oracle globalization settings of the session, thread, and local computer (read-only).
OracleInfoMessageEventArgs Class
The OracleInfoMessageEventArgs object provides event data for the OracleConnection.InfoMessage event.
OracleInfoMessageEventHandler Delegate
The OracleInfoMessageEventHandler delegate represents the signature of the method that handles the OracleConnection.InfoMessage event.
OracleNotificationEventArgs Class
The OnChangedEventArgs class provides event data for a notification.
OracleNotificationRequest Class
An OracleNotificationRequest class represents a notification request to be subscribed in the database.

Not Supported in a .NET Stored Procedure

OracleParameter Class
An OracleParameter object represents a parameter for an OracleCommand.
OracleParameterCollection Class
An OracleParameterCollection object represents a collection of OracleParameters.
OracleRowUpdatedEventArgs Class
The OracleRowUpdatedEventArgs object provides event data for the OracleDataAdapter.RowUpdated event.
OracleRowUpdatedEventHandler Delegate
The OracleRowUpdatedEventHandler delegate represents the signature of the method that handles the OracleDataAdapter.RowUpdated event.
OracleRowUpdatingEventArgs Class
The OracleRowUpdatingEventArgs object provides event data for the OracleDataAdapter.RowUpdating event.
OracleRowUpdatingEventHandler Delegate
The OracleRowUpdatingEventHandler delegate represents the signature of the method that handles the OracleDataAdapter.RowUpdating event.
OracleTransaction Class
An OracleTransaction object represents a local transaction.

Not Supported in a .NET Stored Procedure

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

Oracle.DataAccess.Client Enumerations

Table 1-2 lists the client enumerations.

Table 1-2 Oracle.DataAccess.Client Enumerations

Enumeration Description
FailoverEvent Enumeration
FailoverEvent enumerated values are used to specify the state of the failover.

Not Supported in a .NET Stored Procedure

FailoverReturnCode Enumeration
FailoverReturnCode enumerated values are passed back by the application to the ODP.NET provider to request a retry in case of a failover error, or to continue in case of a successful failover.

Not Supported in a .NET Stored Procedure

FailoverType Enumeration
FailoverType enumerated values are used to indicate the type of failover event that was raised.

Not Supported in a .NET Stored Procedure

OracleCollectionType Enumeration
OracleCollectionType enumerated values specify whether or not the OracleParameter object represents a collection, and if so, specifies the collection type.

Not Supported in a .NET Stored Procedure

OracleDbType Enumeration
OracleDbType enumerated values are used to explicitly specify the OracleDbType of an OracleParameter.
OracleNotificationInfo Enumeration
OracleNotificationInfo enumerated values specify the database event that causes the notification.

Not Supported in a .NET Stored Procedure

OracleNotificationSource Enumeration
OracleNotificationSource enumerated values specify the different sources that cause notification.

Not Supported in a .NET Stored Procedure

OracleNotificationType Enumeration
OracleNotificationType enumerated values specify the different types that cause the notification.

Not Supported in a .NET Stored Procedure

OracleParameterStatus Enumeration
The OracleParameterStatus enumeration type indicates whether a NULL value is fetched from a column, or truncation has occurred during the fetch, or a NULL value is to be inserted into a database column.
OracleXmlCommandType Enumeration
The OracleXmlCommandType enumeration specifies the values that are allowed for the OracleXmlCommandType property of the OracleCommand class.

Oracle.DataAccess.Types Namespace

The Oracle.DataAccess.Types namespace provides classes, structures, and exceptions for Oracle native types that can be used with Oracle Data Provider for .NET.

Oracle.DataAccess.Types Structures

Table 1-3 lists the type structures.

Table 1-3 Oracle.DataAccess.Types Structures

Structure Description
OracleBinary Structure
The OracleBinary structure represents a variable-length stream of binary data.
OracleDate Structure
The OracleDate structure represents the Oracle DATE datatype.
OracleDecimal Structure
The OracleDecimal structure represents an Oracle NUMBER in the database or any Oracle numeric value.
OracleIntervalDS Structure
The OracleIntervalDS structure represents the Oracle INTERVAL DAY TO SECOND datatype.
OracleIntervalYM Structure
The OracleIntervalYM structure represents the Oracle INTERVAL YEAR TO MONTH datatype.
OracleString Structure
The OracleString structure represents a variable-length stream of characters.
OracleTimeStamp Structure
The OracleTimeStamp structure represents the Oracle TimeStamp datatype.
OracleTimeStampLTZ Structure
The OracleTimeStampLTZ structure represents the Oracle TIMESTAMP WITH LOCAL TIME ZONE datatype.
OracleTimeStampTZ Structure
The OracleTimeStampTZ structure represents the Oracle TIMESTAMP WITH TIME ZONE datatype.

Oracle.DataAccess.Types Exceptions

Type Exceptions are thrown only by ODP.NET type structures. Table 1-4 lists the type exceptions.

Table 1-4 Oracle.DataAccess.Types Exceptions

Exception Description
OracleTypeException Class
The OracleTypeException object is the base exception class for handling exceptions that occur in the ODP.NET Types classes.
OracleNullValueException Class
The OracleNullValueException represents an exception that is thrown when trying to access an ODP.NET Types structure that is null.
OracleTruncateException Class
The OracleTruncateException class represents an exception that is thrown when truncation in an ODP.NET Types class occurs.

Oracle.DataAccess.Types Classes

Table 1-5 lists the type classes.

Table 1-5 Oracle.DataAccess.Types Classes

Class Description
OracleBFile Class
An OracleBFile is an object that has a reference to BFILE data. It provides methods for performing operations on BFILE objects.
OracleBlob Class
An OracleBlob object is an object that has a reference to BLOB data. It provides methods for performing operations on BLOB objects.
OracleClob Class
An OracleClob is an object that has a reference to CLOB data. It provides methods for performing operations on CLOB objects.
OracleRefCursor Class
An OracleRefCursor object represents an Oracle REF CURSOR.
OracleXmlStream Class
An OracleXmlStream object represents a sequential read-only stream of XML data stored in an OracleXmlType object.
OracleXmlType Class
An OracleXmlType object represents an Oracle XmlType instance.

PK(NmImPKkUI"OEBPS/FailoverEventEnumeration.htm  Oracle Data Provider for .NET Failover Classes

FailoverEvent Enumeration

FailoverEvent enumerated values are used to specify the state of the failover.

Table 9-7 lists all the FailoverEvent enumeration values with a description of each enumerated value.

Table 9-7 FailoverEvent Enumeration Values

Member Names Description
FailoverEvent.Begin Indicates that failover has detected a lost connection and that failover is starting.
FailoverEvent.End Indicates successful completion of failover.
FailoverEvent.Abort Indicates that failover was unsuccessful, and there is no option of retrying.
FailoverEvent.Error Indicates that failover was unsuccessful, and it gives the application the opportunity to handle the error and retry failover. The application can retry failover by returning FailoverReturnCode.Retry for the event notification.
FailoverEvent.Reauth Indicates that a user handle has been reauthenticated. This applies to the situation where a client has multiple user sessions on a single server connection. During the initial failover, only the active user session is failed over. Other sessions are failed over when the application tries to use them. This is the value passed to the callback during these subsequent failovers.

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll

PK] PKkUIOEBPS/intro004.htm  Introducing Oracle Data Provider for .NET

Using ODP.NET Client Provider in a Simple Application

The following is a simple C# application that connects to Oracle Database and displays its version number before disconnecting:

// C#
 
using System; 
using Oracle.DataAccess.Client;
 
class Sample
{
  static void Main()
  { 
    // Connect to Oracle
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    // Display Version Number
    Console.WriteLine("Connected to Oracle " + con.ServerVersion); 
 
    // Close and Dispose OracleConnection
    con.Close();
    con.Dispose();
  }
}


Note:

Additional samples are provided in the ORACLE_BASE\ORACLE_HOME\ODP.NET\Samples directory.

PK$ PKkUIOEBPS/featUnique.htm'T Features of Oracle Data Provider for .NET

Guaranteeing Uniqueness in Updating DataSet to Database

This section describes how the OracleDataAdapter object configures the PrimaryKey and Constraints properties of the DataTable object which guarantee uniqueness when the OracleCommandBuilder object is updating DataSet changes to the database.

Using the OracleCommandBuilder object to dynamically generate DML statements to be executed against the database is one of the ways to reconcile changes made in a single DataTable object with the database.

In this process, the OracleCommandBuilder object must not be allowed to generate DML statements that may affect (update or delete) more that a single row in the database when reconciling a single DataRow change. Otherwise the OracleCommandBuilder could corrupt data in the database.

To guarantee that each DataRow object change affects only a single row, there must be a set of DataColumn objects in the DataTable for which all rows in the DataTable have a unique set of values. The set of DataColumn objects indicated by the properties DataTable.PrimaryKey and DataTable.Constraints meets this requirement. The OracleCommandBuilder object determines uniqueness in the DataTable by checking if the DataTable.PrimaryKey is not a null value or if there exists a UniqueConstraint object in the DataTable.Constraints collection.

This discussion first explains what constitutes uniqueness in DataRow objects and then explains how to maintain that uniqueness while updating, through the DataTable property configuration.

This section includes the following topics:

What Constitutes Uniqueness in DataRow Objects?

This section describes the minimal conditions that must be met to guarantee uniqueness of DataRow objects. The condition of uniqueness must be guaranteed before the DataTable.PrimaryKey and DataTable.Constraints properties can be configured, as described in the next section.

Uniqueness is guaranteed in a DataTable object if any one of the following is true:

  • All the columns of the primary key are in the select list of the OracleDataAdapter.SelectCommand property.

  • All the columns of a unique constraint are in the select list of the OracleDataAdapter.SelectCommand property, with at least one involved column having a NOT NULL constraint defined on it.

  • All the columns of a unique index are in the select list of the OracleDataAdapter.SelectCommand property, with at least one of the involved columns having a NOT NULL constraint defined on it.

  • A ROWID is present in the select list of the OracleDataAdapter.SelectCommand property.


Note:

A set of columns, on which a unique constraint has been defined or a unique index has been created, requires at least one column that cannot be null for the following reason: if all the columns of the column set can be null, then multiple rows could exist that have a NULL value for each column in the column set. This would violate the uniqueness condition that each row has a unique set of values for the column set.

Configuring PrimaryKey and Constraints Properties

If the minimal conditions described in "What Constitutes Uniqueness in DataRow Objects?" are met, then the DataTable.PrimaryKey or DataTable.Constraints properties can be set.

After these properties are set, the OracleCommandBuilder object can determine uniqueness in the DataTable by checking the DataTable.PrimaryKey property or the presence of a UniqueConstraint object in the DataTable.Constraints collection. Once uniqueness is determined, the OracleCommandBuilder object can safely generate DML statements to update the database.

The OracleDataAdapter.FillSchema method attempts to set these properties according to this order of priority:

  1. If the primary key is returned in the select list, it is set as the DataTable.PrimaryKey property.

  2. If a set of columns that meets the following criteria is returned in the select list, it is set as the DataTable.PrimaryKey property.

    Criteria: The set of columns has a unique constraint defined on it or a unique index created on it, with each column having a NOT NULL constraint defined on it.

  3. If a set of columns that meets the following criteria is returned in the select list, a UniqueConstraint object is added to the DataTable.Constraints collection, but the DataTable.PrimaryKey property is not set.

    Criteria: The set of columns has a unique constraint defined on it or a unique index created on it, with at least one column having a NOT NULL constraint defined on it.

  4. If a ROWID is part of the select list, it is set as the DataTable.PrimaryKey property.

Additionally, the OracleDataAdapter.FillSchema method performs as follows:

  • Setting the DataTable.PrimaryKey property implicitly creates a UniqueConstraint object.

  • If a column is part of the DataTable.PrimaryKey property or the UniqueConstraint object, or both, it will be repeated for each occurrence of the column in the select list.

Updating Without PrimaryKey and Constraints Configuration

If the DataTable.PrimaryKey or Constraints properties have not been configured, for example, if the application has not called the OracleDataAdapter.FillSchema method, the OracleCommandBuilder object directly checks the select list of the OracleDataAdapter.SelectCommand property to determine if it guarantees uniqueness in the DataTable. However this check results in a database round-trip to retrieve the metadata for the SELECT statement of the OracleDataAdapter.SelectCommand.

Note that OracleCommandBuilder object cannot update a DataTable created from PL/SQL statements because they do not return any key information in their metadata.

PKZa`''PKkUIOEBPS/install003.htme Installing and Configuring Oracle Data Provider for .NET

File Locations After Installation

The Oracle.DataAccess.dll assembly is installed in the ORACLE_BASE\ORACLE_HOME\bin directory.

Documentation and the readme.txt file are installed in the ORACLE_BASE\ORACLE_HOME\ODP.NET\doc directory.

Samples are provided in the ORACLE_BASE\ORACLE_HOME\ODP.NET\Samples directory.

PKRj e PKkUIOEBPS/title.htmX Oracle Data Provider for .NET Developer's Guide, 10g Release 2 (10.2)

Oracle® Data Provider for .NET

Developer's Guide

10g Release 2 (10.2)

B14307-01

June 2005


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

B14307-01

Copyright © 2002, 2005, Oracle. All rights reserved.

Primary Author:  Janis Greenberg

Contributing Authors: Riaz Ahmed, Kiminari Akiyama, Steven Caminez, Naveen Doraiswamy, Neeraj Gupta, Sinclair Hsu, Alex Keh, Chithra Ramamurthy, Ashish Shah, Martha Woo

The Programs (which include both the software and documentation) contain proprietary information; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent, and other intellectual and industrial property laws. Reverse engineering, disassembly, or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited.

The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. This document is not warranted to be error-free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose.

If the Programs are delivered to the United States Government or anyone licensing or using the Programs on behalf of the United States Government, the following notice is applicable:

U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the Programs, including documentation and technical data, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement, and, to the extent applicable, the additional rights set forth in FAR 52.227-19, Commercial Computer Software—Restricted Rights (June 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065

The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup, redundancy and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and we disclaim liability for any damages caused by such use of the Programs.

Oracle, JD Edwards, PeopleSoft, and Retek are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

The Programs may provide links to Web sites and access to content, products, and services from third parties. Oracle is not responsible for the availability of, or any content provided on, third-party Web sites. You bear all risks associated with the use of such content. If you choose to purchase any products or services from a third party, the relationship is directly between you and the third party. Oracle is not responsible for: (a) the quality of third-party products or services; or (b) fulfilling any of the terms of the agreement with the third party, including delivery of products or services and warranty obligations related to purchased products or services. Oracle is not responsible for any loss or damage of any sort that you may incur from dealing with any third party.

PK·EX]XPKkUIOEBPS/OracleStringStructure.htm Oracle Data Provider for .NET Types Structures

OracleString Structure

The OracleString structure represents a variable-length stream of characters to be stored in or retrieved from a database.

Class Inheritance

Object

  ValueType

    OracleString

Declaration

// C#
public struct OracleString : IComparable

Thread Safety

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

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class OracleStringSample
{
  static void Main()
  {
    // Initialize OracleString structs
    OracleString string1 = new OracleString("AAA");
    
    // Display the string "AAA"
    Console.WriteLine("{0} has length of {1}", string1, string1.Length);
 
    // Contatenate characters to string1 until the length is 5 
    while (string1.Length < 5)
      string1 = OracleString.Concat(string1,"a");
      
    // Display the string of "AAAaa"
    Console.WriteLine("{0} has length of {1}", string1, string1.Length);
  }
}

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll


OracleString Members

OracleString members are listed in the following tables:

OracleString Constructors

OracleString constructors are listed in Table 11-74

Table 11-74 OracleString Constructors

Constructor Description
OracleString Constructors Instantiates a new instance of OracleString structure (Overloaded)

OracleString Static Fields

The OracleString static fields are listed in Table 11-75.

Table 11-75 OracleString Static Fields

Field Description
Null Represents a null value that can be assigned to an instance of the OracleString structure

OracleString Static Methods

The OracleString static methods are listed in Table 11-76.

Table 11-76 OracleString Static Methods

Methods Description
Concat Concatenates two OracleString instances and returns a new OracleString instance that represents the result
Equals Determines if two OracleString values are equal (Overloaded)
GreaterThan Determines whether or not the first of two OracleString values is greater than the second
GreaterThanOrEqual Determines whether or not the first of two OracleString values is greater than or equal to the second
LessThan Determines whether or not the first of two OracleString values is less than the second
LessThanOrEqual Determines whether or not the first of two OracleString values is less than or equal to the second
NotEquals Determines whether two OracleString values are not equal

OracleString Static Operators

The OracleString static operators are listed in Table 11-77.

Table 11-77 OracleString Static Operators

Operator Description
operator + Concatenates two OracleString values
operator == Determines if two OracleString values are equal
operator > Determines if the first of two OracleString values is greater than the second
operator >= Determines if the first of two OracleString values is greater than or equal to the second
operator != Determines if the two OracleString values are not equal
operator < Determines if the first of two OracleString values is less than the second
operator <= Determines if two OracleString values are not equal

OracleString Type Conversions

The OracleString type conversions are listed in Table 11-78.

Table 11-78 OracleString Type Conversions

Operator Description
explicit operator string Converts the supplied OracleString to a string instance
implicit operator OracleString Converts the supplied string to an OracleString instance

OracleString Properties

The OracleString properties are listed in Table 11-79.

Table 11-79 OracleString Properties

Properties Description
IsCaseIgnored Indicates whether or not case should be ignored when performing string comparison
IsNull Indicates whether or not the current instance has a null value
Item Obtains the particular character in an OracleString using an index.
Length Returns the length of the OracleString

OracleString Methods

The OracleString methods are listed in Table 11-80.

Table 11-80 OracleString Methods

Methods Description
Clone Returns a copy of the current OracleString instance
CompareTo Compares the current OracleString instance to the supplied object, and returns an integer that represents their relative values
Equals Determines whether or not an object has the same string value as the current OracleString structure (Overloaded)
GetHashCode Returns a hash code for the OracleString instance
GetNonUnicodeBytes Returns an array of bytes, containing the contents of the OracleString, in the client character set format
GetType Inherited from Object
GetUnicodeBytes Returns an array of bytes, containing the contents of the OracleString, in Unicode format
ToString Converts the current OracleString instance to a string


OracleString Constructors

The OracleString constructors create new instances of the OracleString structure.

Overload List:

  • OracleString(string)

    This constructor creates a new instance of the OracleString structure and sets its value using a string.

  • OracleString(string, bool)

    This constructor creates a new instance of the OracleString structure and sets its value using a string and specifies if case is ignored in comparison.

  • OracleString(byte [ ], bool)

    This constructor creates a new instance of the OracleString structure and sets its value using a byte array and specifies if the supplied byte array is Unicode encoded.

  • OracleString(byte [ ], bool, bool)

    This constructor creates a new instance of the OracleString structure and sets its value using a byte array and specifies the following: if the supplied byte array is Unicode encoded and if case is ignored in comparison.

  • OracleString(byte [ ], int, int, bool)

    This constructor creates a new instance of the OracleString structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, and if the supplied byte array is Unicode encoded.

  • OracleString(byte [ ], int, int, bool, bool)

    This constructor creates a new instance of the OracleString structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, if the supplied byte array is Unicode encoded, and if case is ignored in comparison.

OracleString(string)

This constructor creates a new instance of the OracleString structure and sets its value using a string.

Declaration

// C#
public OracleString(string data);

Parameters

  • data

    A string value.

OracleString(string, bool)

This constructor creates a new instance of the OracleString structure and sets its value using a string and specifies if case is ignored in comparison.

Declaration

// C#
public OracleString(string data, bool isCaseIgnored);

Parameters

  • data

    A string value.

  • isCaseIgnored

    Specifies if case is ignored in comparison. Specifies true if case is to be ignored; otherwise, specifies false.

OracleString(byte [ ], bool)

This constructor creates a new instance of the OracleString structure and sets its value using a byte array and specifies if the supplied byte array is Unicode encoded.

Declaration

// C#
public OracleString(byte[] data, bool fUnicode);

Parameters

  • data

    Byte array data for the new OracleString.

  • fUnicode

    Specifies if the supplied data is Unicode encoded. Specifies true if Unicode encoded; otherwise, false.

Exceptions

ArgumentNullException - The data parameter is null.

OracleString(byte [ ], bool, bool)

This constructor creates a new instance of the OracleString structure and sets its value using a byte array and specifies the following: if the supplied byte array is Unicode encoded and if case is ignored in comparison.

Declaration

// C#
public OracleString(byte[] data, bool fUnicode, bool isCaseIgnored);

Parameters

  • data

    Byte array data for the new OracleString.

  • fUnicode

    Specifies if the supplied data is Unicode encoded. Specifies true if Unicode encoded; otherwise, false.

  • isCaseIgnored

    Specifies if case is ignored in comparison. Specifies true if case is to be ignored; otherwise, specifies false.

Exceptions

ArgumentNullException - The data parameter is null.

OracleString(byte [ ], int, int, bool)

This constructor creates a new instance of the OracleString structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, and if the supplied byte array is Unicode encoded.

Declaration

// C#
public OracleString(byte[] data, int index, int count, bool fUnicode);

Parameters

  • data

    Byte array data for the new OracleString.

  • index

    The starting index to copy from data.

  • count

    The number of bytes to copy.

  • fUnicode

    Specifies if the supplied data is Unicode encoded. Specifies true if Unicode encoded; otherwise, false.

Exceptions

ArgumentNullException - The data parameter is null.

ArgumentOutOfRangeException - The count parameter is less than zero.

IndexOutOfRangeException - The index parameter is greater than or equal to the length of data or less than zero.

OracleString(byte [ ], int, int, bool, bool)

This constructor creates a new instance of the OracleString structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, if the supplied byte array is Unicode encoded, and if case is ignored in comparison.

Declaration

// C#
public OracleString(byte[] data, int index, int count, bool fUnicode,
 bool isCaseIgnored);

Parameters

  • data

    Byte array data for the new OracleString.

  • index

    The starting index to copy from data.

  • count

    The number of bytes to copy.

  • fUnicode

    Specifies if the supplied data is Unicode encoded. Specifies true if Unicode encoded; otherwise, false.

  • isCaseIgnored

    Specifies if case is ignored in comparison. Specifies true if case is to be ignored; otherwise, specifies false.

Exceptions

ArgumentNullException - The data parameter is null.

ArgumentOutOfRangeException - The count parameter is less than zero.

IndexOutOfRangeException - The index parameter is greater than or equal to the length of data or less than zero.


OracleString Static Fields

The OracleString static fields are listed in Table 11-81.

Table 11-81 OracleString Static Fields

Field Description
Null Represents a null value that can be assigned to an instance of the OracleString structure

Null

This static field represents a null value that can be assigned to an instance of the OracleString structure.

Declaration

// C#
public static readonly OracleString Null;

OracleString Static Methods

The OracleString static methods are listed in Table 11-82.

Table 11-82 OracleString Static Methods

Methods Description
Concat Concatenates two OracleString instances and returns a new OracleString instance that represents the result
Equals Determines if two OracleString values are equal (Overloaded)
GreaterThan Determines whether or not the first of two OracleString values is greater than the second
GreaterThanOrEqual Determines whether or not the first of two OracleString values is greater than or equal to the second
LessThan Determines whether or not the first of two OracleString values is less than the second
LessThanOrEqual Determines whether or not the first of two OracleString values is less than or equal to the second
NotEquals Determines whether two OracleString values are not equal

Concat

This static method concatenates two OracleString instances and returns a new OracleString instance that represents the result.

Declaration

// C#
public static OracleString Concat(OracleString str1, OracleString str2);

Parameters

  • str1

    The first OracleString.

  • str2

    The second OracleString.

Return Value

An OracleString.

Remarks

If either argument has a null value, the returned OracleString structure has a null value.

Equals

Overloads Object

This static method determines whether or not the two OracleStrings being compared are equal.

Declaration

// C#
public static bool Equals(OracleString str1, OracleString str2);

Parameters

  • str1

    The first OracleString.

  • str2

    The second OracleString.

Return Value

Returns true if the two OracleStrings being compared are equal; returns false otherwise.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

GreaterThan

This static method determines whether or not the first of two OracleString values is greater than the second.

Declaration

// C#
public static bool GreaterThan(OracleString str1, OracleString str2);

Parameters

  • str1

    The first OracleString.

  • str2

    The second OracleString.

Return Value

Returns true if the first of two OracleStrings is greater than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

GreaterThanOrEqual

This static method determines whether or not the first of two OracleString values is greater than or equal to the second.

Declaration

// C#
public static bool GreaterThanOrEqual(OracleString str1, 
    OracleString str2);

Parameters

  • str1

    The first OracleString.

  • str2

    The second OracleString.

Return Value

Returns true if the first of two OracleStrings is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

LessThan

This static method determines whether or not the first of two OracleString values is less than the second.

Declaration

// C#
public static bool LessThan(OracleString str1, OracleString str2);

Parameters

  • str1

    The first OracleString.

  • str2

    The second OracleString.

Return Value

Returns true if the first is less than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

LessThanOrEqual

This static method determines whether or not the first of two OracleString values is less than or equal to the second.

Declaration

// C#
public static bool LessThanOrEqual(OracleString str1, OracleString str2);

Parameters

  • str1

    The first OracleString.

  • str2

    The second OracleString.

Return Value

Returns true if the first is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

NotEquals

This static method determines whether two OracleString values are not equal.

Declaration

// C#
public static bool NotEquals(OracleString str1, OracleString str2);

Parameters

  • str1

    The first OracleString.

  • str2

    The second OracleString.

Return Value

Returns true if the two OracleString instances are not equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.


OracleString Static Operators

The OracleString static operators are listed in Table 11-83.

Table 11-83 OracleString Static Operators

Operator Description
operator + Concatenates two OracleString values
operator == Determines if two OracleString values are equal
operator > Determines if the first of two OracleString values is greater than the second
operator >= Determines if the first of two OracleString values is greater than or equal to the second
operator != Determines if the two OracleString values are not equal
operator < Determines if the first of two OracleString values is less than the second
operator <= Determines if two OracleString values are not equal

operator +

This static operator concatenates two OracleString values.

Declaration

// C#
public static OracleString operator + (OracleString value1, OracleString value2);

Parameters

  • value1

    The first OracleString.

  • value2

    The second OracleString.

Return Value

An OracleString.

Remarks

If either argument has a null value, the returned OracleString structure has a null value.

operator ==

This static operator determines if two OracleString values are equal.

Declaration

// C#
public static bool operator == (OracleString value1, OracleString value2);

Parameters

  • value1

    The first OracleString.

  • value2

    The second OracleString.

Return Value

Returns true if two OracleString values are equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

operator >

This static operator determines if the first of two OracleString values is greater than the second.

Declaration

// C#
public static bool operator > (OracleString value1, OracleString value2);

Parameters

  • value1

    The first OracleString.

  • value2

    The second OracleString.

Return Value

Returns true if the first of two OracleString values is greater than the second; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

operator >=

This static operator determines if the first of two OracleString values is greater than or equal to the second.

Declaration

// C#
public static bool operator >= (OracleString value1, OracleString value2);

Parameters

  • value1

    The first OracleString.

  • value2

    The second OracleString.

Return Value

Returns true if the first of two OracleString values is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

operator !=

This static operator determines if two OracleString values are not equal.

Declaration

// C#
public static bool operator != (OracleString value1, OracleString value2);

Parameters

  • value1

    The first OracleString.

  • value2

    The second OracleString.

Return Value

Returns true if two OracleString values are not equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

operator <

This static operator determines if the first of two OracleStrings is less than the second.

Declaration

// C#
public static bool operator < (OracleString value1, OracleString value2);

Parameters

  • value1

    The first OracleString.

  • value2

    The second OracleString.

Return Value

Returns true if the first of two OracleStrings is less than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString has a null value.

  • Two OracleStrings that contain a null value are equal.

operator <=

This static operator determines if the first of two OracleString values is less than or equal to the second.

Declaration

// C#
public static bool operator <= (OracleString value1, OracleString value1);

Parameters

  • value1

    The first OracleString.

  • value2

    The second OracleString.

Return Value

Returns true if the first of two OracleString values is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.


OracleString Type Conversions

The OracleString type conversions are listed in Table 11-84.

Table 11-84 OracleString Type Conversions

Operator Description
explicit operator string Converts the supplied OracleString to a string instance
implicit operator OracleString Converts the supplied string to an OracleString instance

explicit operator string

This type conversion operator converts the supplied OracleString to a string.

Declaration

//C#
public static explicit operator string (OracleString value1);

Parameters

  • value1

    The supplied OracleString.

Return Value

string

Exceptions

OracleNullValueException - The OracleString structure has a null value.

implicit operator OracleString

This type conversion operator converts the supplied string to an OracleString.

Declaration

// C#
public static implicit operator OracleString (string value1);

Parameters

  • value1

    The supplied string.

Return Value

An OracleString.


OracleString Properties

The OracleString properties are listed in Table 11-85.

Table 11-85 OracleString Properties

Properties Description
IsCaseIgnored Indicates whether or not case should be ignored when performing string comparison
IsNull Indicates whether or not the current instance has a null value
Item Obtains the particular character in an OracleString using an index.
Length Returns the length of the OracleString

IsCaseIgnored

This property indicates whether or not case should be ignored when performing string comparison.

Declaration

//C#
public bool IsCaseIgnored {get;set;}

Property Value

Returns true if string comparison must ignore case; otherwise false.

Remarks

Default value is true.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class IsCaseIgnoredSample
{
  static void Main()
  {
    OracleString string1 = new OracleString("aAaAa");
    OracleString string2 = new OracleString("AaAaA");
 
    // Ignore case for comparisons
    string1.IsCaseIgnored = true;
    string2.IsCaseIgnored = true;
 
    // Same; Prints 0
    Console.WriteLine(string1.CompareTo(string2));
 
    // Make comparisons case sensitive   
    // Note that IsCaseIgnored must be set to false for both 
    //   OracleStrings; otherwise an exception is thrown
    string1.IsCaseIgnored = false;
    string2.IsCaseIgnored = false;
 
    // Different; Prints nonzero value
    Console.WriteLine(string1.CompareTo(string2));
  }
}

IsNull

This property indicates whether or not the current instance contains a null value.

Declaration

// C#
public bool IsNull {get;}

Property Value

Returns true if the current instance contains has a null value; otherwise, returns false.

Item

This property obtains the particular character in an OracleString using an index.

Declaration

// C#
public char Item {get;}

Property Value

A char value.

Exceptions

OracleNullValueException - The current instance has a null value.

Length

This property returns the length of the OracleString.

Declaration

// C#
public int Length {get;}

Property Value

A int value.

Exceptions

OracleNullValueException - The current instance has a null value.


OracleString Methods

The OracleString methods are listed in Table 11-86.

Table 11-86 OracleString Methods

Methods Description
Clone Returns a copy of the current OracleString instance
CompareTo Compares the current OracleString instance to the supplied object, and returns an integer that represents their relative values
Equals Determines whether or not an object has the same string value as the current OracleString structure (Overloaded)
GetHashCode Returns a hash code for the OracleString instance
GetNonUnicodeBytes Returns an array of bytes, containing the contents of the OracleString, in the client character set format
GetType Inherited from Object
GetUnicodeBytes Returns an array of bytes, containing the contents of the OracleString, in Unicode format
ToString Converts the current OracleString instance to a string

Clone

This method creates a copy of an OracleString instance.

Declaration

// C#
public OracleString Clone();

Return Value

An OracleString structure.

Remarks

The cloned object has the same property values as that of the object being cloned.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class CloneSample
{
  static void Main()
  {
    OracleString str1 = new OracleString("aAaAa");
    OracleString str2 = str1.Clone();
 
    // The OracleStrings are same; Prints 0
    Console.WriteLine(str1.CompareTo(str2));
  }
}

CompareTo

This method compares the current OracleString instance to the supplied object, and returns an integer that represents their relative values.

Declaration

// C#
public int CompareTo(object obj);

Parameters

  • obj

    The object being compared to the current instance.

Return Value

The method returns a number that is:

  • Less than zero: if the current OracleString value is less than obj.

  • Zero: if the current OracleString value is equal to obj.

  • Greater than zero: if the current OracleString value is greater than obj.

Implements

IComparable

Exceptions

ArgumentException - The obj parameter is not of type OracleString.

Remarks

The following rules apply to the behavior of this method.

  • The comparison must be between OracleStrings. For example, comparing an OracleString instance with an OracleBinary instance is not allowed. When an OracleString is compared with a different type, an ArgumentException is thrown.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

Equals

This method determines whether or not supplied object is an instance of OracleString and has the same values as the current OracleString instance.

Declaration

// C#
public override bool Equals(object obj);

Parameters

  • obj

    An object being compared.

Return Value

Returns true if the supplied object is an instance of OracleString and has the same values as the current OracleString instance; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleString that has a value is greater than an OracleString that has a null value.

  • Two OracleStrings that contain a null value are equal.

GetHashCode

Overrides Object

This method returns a hash code for the OracleString instance.

Declaration

// C#
public override int GetHashCode();

Return Value

A number that represents the hash code.

GetNonUnicodeBytes

This method returns an array of bytes, containing the contents of the OracleString, in the client character set format.

Declaration

// C#
public byte[] GetNonUnicodeBytes();

Return Value

A byte array that contains the contents of the OracleString in the client character set format.

Remarks

If the current instance has a null value, an OracleNullValueException is thrown.

GetUnicodeBytes

This method returns an array of bytes, containing the contents of the OracleString in Unicode format.

Declaration

// C#
public byte[] GetUnicodeBytes();

Return Value

A byte array that contains the contents of the OracleString in Unicode format.

Remarks

If the current instance has a null value, an OracleNullValueException is thrown.

ToString

Overrides Object

This method converts the current OracleString instance to a string.

Declaration

// C#
public override string ToString();

Return Value

A string.

Remarks

If the current OracleString instance has a null value, the string contains "null".

PKV\uPKkUI+OEBPS/OracleNotificationInfoEnumeration.htmJ Database Change Notification

OracleNotificationInfo Enumeration

OracleNotificationInfo enumerated values specify the database event that causes the notification.

Table 7-29 lists all the OracleNotificationInfo enumeration values with a description of each enumerated value.

Table 7-29 OracleNotificationInfo Members

Member Name Description
Insert A row is inserted.
Delete A row is deleted.
Update A row is updated.
Startup A database starts.
Shutdown A database shuts down.
Shutdown_Any A database instance in a Real Application Cluster (RAC) environment shuts down.
Alter An object is altered.
Drop An object or database is dropped.
End A registration is removed.
Error A notification error occurs.

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll

PK8OJPKkUI#OEBPS/OracleIntervalDSStructure.htm Oracle Data Provider for .NET Types Structures

OracleIntervalDS Structure

The OracleIntervalDS structure represents the Oracle INTERVAL DAY TO SECOND datatype to be stored in or retrieved from a database. Each OracleIntervalDS stores a period of time in term of days, hours, minutes, seconds, and fractional seconds.

Class Inheritance

Object

  ValueType

    OracleIntervalDS

Declaration

// C#
public struct OracleIntervalDS : IComparable

Thread Safety

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

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class OracleIntervalDSSample
{
  static void Main()
  {
    OracleIntervalDS iDSMax = OracleIntervalDS.MaxValue;
    double totalDays = iDSMax.TotalDays;
 
    totalDays -= 1;
    OracleIntervalDS iDSMax_1 = new OracleIntervalDS(totalDays);
    
    // Calculate the difference 
    OracleIntervalDS iDSDiff = iDSMax - iDSMax_1;
    
    // Prints "iDSDiff.ToString() = +000000000 23:59:59.999999999"
    Console.WriteLine("iDSDiff.ToString() = " + iDSDiff.ToString());
  }
}

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll


OracleIntervalDS Members

OracleIntervalDS members are listed in the following tables:

OracleIntervalDS Constructors

OracleIntervalDS constructors are listed in Table 11-48

Table 11-48 OracleIntervalDS Constructors

Constructor Description
OracleIntervalDS Constructors Instantiates a new instance of OracleIntervalDS structure (Overloaded)

OracleIntervalDS Static Fields

The OracleIntervalDS static fields are listed in Table 11-49.

Table 11-49 OracleIntervalDS Static Fields

Field Description
MaxValue Represents the maximum valid time interval for an OracleIntervalDS structure
MinValue Represents the minimum valid time interval for an OracleIntervalDS structure
Null Represents a null value that can be assigned to an OracleIntervalDS instance
Zero Represents a zero value for an OracleIntervalDS structure

OracleIntervalDS Static Methods

The OracleIntervalDS static methods are listed in Table 11-50.

Table 11-50 OracleIntervalDS Static Methods

Methods Description
Equals Determines whether or not two OracleIntervalDS values are equal (Overloaded)
GreaterThan Determines whether or not one OracleIntervalDS value is greater than another
GreaterThanOrEqual Determines whether or not one OracleIntervalDS value is greater than or equal to another
LessThan Determines whether or not one OracleIntervalDS value is less than another
LessThanOrEqual Determines whether or not one OracleIntervalDS value is less than or equal to another
NotEquals Determines whether or not two OracleIntervalDS values are not equal
Parse Returns an OracleIntervalDS structure and sets its value for time interval using a string
SetPrecision Returns a new instance of an OracleIntervalDS with the specified day precision and fractional second precision

OracleIntervalDS Static Operators

The OracleIntervalDS static operators are listed in Table 11-51.

Table 11-51 OracleIntervalDS Static Operators

Operator Description
operator + Adds two OracleIntervalDS values
operator == Determines whether or not two OracleIntervalDS values are equal
operator > Determines whether or not one OracleIntervalDS value is greater than another
operator >= Determines whether or not one OracleIntervalDS value is greater than or equal to another
operator != Determines whether or not two OracleIntervalDS values are not equal
operator < Determines whether or not one OracleIntervalDS value is less than another
operator <= Determines whether or not one OracleIntervalDS value is less than or equal to another
operator - Subtracts one OracleIntervalDS value from another
operator - Negates an OracleIntervalDS structure
operator * Multiplies an OracleIntervalDS value by a number
operator / Divides an OracleIntervalDS value by a number

OracleIntervalDS Type Conversions

The OracleIntervalDS type conversions are listed in Table 11-52.

Table 11-52 OracleIntervalDS Type Conversions

Operator Description
explicit operator TimeSpan Converts an OracleIntervalDS structure to a TimeSpan structure
explicit operator OracleIntervalDS Converts a string to an OracleIntervalDS structure
implicit operator OracleIntervalDS Converts a TimeSpan structure to an OracleIntervalDS structure

OracleIntervalDS Properties

The OracleIntervalDS properties are listed in Table 11-53.

Table 11-53 OracleIntervalDS Properties

Properties Description
BinData Returns an array of bytes that represents the Oracle INTERVAL DAY TO SECOND in Oracle internal format
Days Gets the days component of an OracleIntervalDS
Hours Gets the hours component of an OracleIntervalDS
IsNull Indicates whether or not the current instance has a null value
Milliseconds Gets the milliseconds component of an OracleIntervalDS
Minutes Gets the minutes component of an OracleIntervalDS
Nanoseconds Gets the nanoseconds component of an OracleIntervalDS
Seconds Gets the seconds component of an OracleIntervalDS
TotalDays Returns the total number, in days, that represent the time period in the OracleIntervalDS structure
Value Specifies the time interval that is stored in the OracleIntervalDS structure

OracleIntervalDS Methods

The OracleIntervalDS methods are listed in Table 11-54.

Table 11-54 OracleIntervalDS Methods

Methods Description
CompareTo Compares the current OracleIntervalDS instance to an object, and returns an integer that represents their relative values
Equals Determines whether or not the specified object has the same time interval as the current instance (Overloaded)
GetHashCode Returns a hash code for the OracleIntervalDS instance
GetType Inherited from Object
ToString Converts the current OracleIntervalDS structure to a string


OracleIntervalDS Constructors

OracleIntervalDS constructors create a new instance of the OracleIntervalDS structure.

Overload List:

  • OracleIntervalDS(TimeSpan)

    This constructor creates a new instance of the OracleIntervalDS structure and sets its value using a TimeSpan structure.

  • OracleIntervalDS(string)

    This constructor creates a new instance of the OracleIntervalDS structure and sets its value using a string that indicates a period of time.

  • OracleIntervalDS(double)

    This constructor creates a new instance of the OracleIntervalDS structure and sets its value using the total number of days.

  • OracleIntervalDS(int, int, int, int, double)

    This constructor creates a new instance of the OracleIntervalDS structure and sets its value using the supplied days, hours, minutes, seconds and milliseconds.

  • OracleIntervalDS(int, int, int, int, int)

    This constructor creates a new instance of the OracleIntervalDS structure and sets its value using the supplied days, hours, minutes, seconds, and nanoseconds.

  • OracleIntervalDS(byte[ ])

    This constructor creates a new instance of the OracleIntervalDS structure and sets its value to the provided byte array, which is in an internal Oracle INTERVAL DAY TO SECOND format.

OracleIntervalDS(TimeSpan)

This constructor creates a new instance of the OracleIntervalDS structure and sets its value using a TimeSpan structure.

Declaration

// C#
public OracleIntervalDS(TimeSpan ts); 

Parameters

  • ts

    A TimeSpan structure.

OracleIntervalDS(string)

This constructor creates a new instance of the OracleIntervalDS structure and sets its value using a string that indicates a period of time.

Declaration

// C#
public OracleIntervalDS(string intervalStr); 

Parameters

  • intervalStr

    A string representing the Oracle INTERVAL DAY TO SECOND.

Exceptions

ArgumentException - The intervalStr parameter is not in the valid format or has an invalid value.

ArgumentNullException - The intervalStr parameter is null.

Remarks

The value specified in the supplied intervalStr must be in Day HH:MI:SSxFF format.

Example

"1 2:3:4.99" means 1 day, 2 hours, 3 minutes, 4 seconds, and 990 milliseconds or 1 day, 2 hours, 3 minutes, 4 seconds, and 990000000 nanoseconds.

OracleIntervalDS(double)

This constructor creates a new instance of the OracleIntervalDS structure and sets its value using the total number of days.

Declaration

// C#
public OracleIntervalDS(double totalDays);

Parameters

  • totalDays

    The supplied total number of days for a time interval. Range of days is -1000,000,000 < totalDays < 1000,000,000.

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleIntervalDS.

OracleIntervalDS(int, int, int, int, double)

This constructor creates a new instance of the OracleIntervalDS structure and sets its value using the supplied days, hours, minutes, seconds, and milliseconds.

Declaration

// C#
public OracleIntervalDS (int days, int hours, int minutes, int seconds,
   double milliSeconds); 

Parameters

  • days

    The days provided. Range of day is (-999,999,999 to 999,999,999).

  • hours

    The hours provided. Range of hour is (-23 to 23).

  • minutes

    The minutes provided. Range of minute is (-59 to 59).

  • seconds

    The seconds provided. Range of second is (-59 to 59).

  • milliSeconds

    The milliseconds provided. Range of millisecond is (- 999.999999 to 999.999999).

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleIntervalDS.

Remarks

The sign of all the arguments must be the same.

OracleIntervalDS(int, int, int, int, int)

This constructor creates a new instance of the OracleIntervalDS structure and sets its value using the supplied days, hours, minutes, seconds, and nanoseconds.

Declaration

// C#
public OracleIntervalDS (int days, int hours, int minutes, int seconds,
   int nanoseconds); 

Parameters

  • days

    The days provided. Range of day is (-999,999,999 to 999,999,999).

  • hours

    The hours provided. Range of hour is (-23 to 23).

  • minutes

    The minutes provided. Range of minute is (-59 to 59).

  • seconds

    The seconds provided. Range of second is (-59 to 59).

  • nanoseconds

    The nanoseconds provided. Range of nanosecond is (-999,999,999 to 999,999,999)

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleIntervalDS.

Remarks

The sign of all the arguments must be the same.

OracleIntervalDS(byte[ ])

This constructor creates a new instance of the OracleIntervalDS structure and sets its value to the provided byte array, which is in an internal Oracle INTERVAL DAY TO SECOND format.

Declaration

// C#
public OracleIntervalDS (byte[ ] bytes);

Parameters

  • bytes

    A byte array that is in an internal Oracle INTERVAL DAY TO SECOND format.

Exceptions

ArgumentException - bytes is not in internal Oracle INTERVAL DAY TO SECOND format, or bytes is not a valid Oracle INTERVAL DAY TO SECOND.

ArgumentNullException - bytes is null.


OracleIntervalDS Static Fields

The OracleIntervalDS static fields are listed in Table 11-55.

Table 11-55 OracleIntervalDS Static Fields

Field Description
MaxValue Represents the maximum valid time interval for an OracleIntervalDS structure
MinValue Represents the minimum valid time interval for an OracleIntervalDS structure
Null Represents a null value that can be assigned to an OracleIntervalDS instance
Zero Represents a zero value for an OracleIntervalDS structure

MaxValue

This static field represents the maximum value for an OracleIntervalDS structure.

Declaration

// C#
public static readonly OracleIntervalDS MaxValue;

Remarks

Maximum values:

  • Day: 999999999

  • hour: 23

  • minute is 59

  • second: 59

  • nanosecond: 999999999

MinValue

This static field represents the minimum value for an OracleIntervalDS structure.

Declaration

// C#
public static readonly OracleIntervalDS MinValue;

Remarks

Minimum values:

  • Day: -999999999

  • hour: -23

  • minute: -59

  • second: -59

  • nanosecond: -999999999

Null

This static field represents a null value that can be assigned to an OracleIntervalDS instance.

Declaration

// C#
public static readonly OracleIntervalDS Null;

Zero

This static field represents a zero value for an OracleIntervalDS structure.

Declaration

// C#
public static readonly OracleIntervalDS Zero;

OracleIntervalDS Static Methods

The OracleIntervalDS static methods are listed in Table 11-56.

Table 11-56 OracleIntervalDS Static Methods

Methods Description
Equals Determines whether or not two OracleIntervalDS values are equal (Overloaded)
GreaterThan Determines whether or not one OracleIntervalDS value is greater than another
GreaterThanOrEqual Determines whether or not one OracleIntervalDS value is greater than or equal to another
LessThan Determines whether or not one OracleIntervalDS value is less than another
LessThanOrEqual Determines whether or not one OracleIntervalDS value is less than or equal to another
NotEquals Determines whether or not two OracleIntervalDS values are not equal
Parse Returns an OracleIntervalDS structure and sets its value for time interval using a string
SetPrecision Returns a new instance of an OracleIntervalDS with the specified day precision and fractional second precision

Equals

This static method determines whether or not two OracleIntervalDS values are equal.

Declaration

// C#
public static bool Equals(OracleIntervalDS val1, OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

If the two OracleIntervalDS structures represent the same time interval, returns true; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

GreaterThan

This static method determines whether or not the first of two OracleIntervalDS values is greater than the second.

Declaration

// C#
public static bool GreaterThan(OracleIntervalDS val1, OracleIntervalDS 
   val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the first of two OracleIntervalDS values is greater than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

GreaterThanOrEqual

This static method determines whether or not the first of two OracleIntervalDS values is greater than or equal to the second.

Declaration

// C#
public static bool GreaterThanOrEqual(OracleIntervalDS val1, 
  OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the first of two OracleIntervalDS values is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

LessThan

This static method determines whether or not the first of two OracleIntervalDS values is less than the second.

Declaration

// C#
public static bool LessThan(OracleIntervalDS val1, OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the first of two OracleIntervalDS values is less than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

LessThanOrEqual

This static method determines whether or not the first of two OracleIntervalDS values is less than or equal to the second.

Declaration

// C#
public static bool LessThanOrEqual(OracleIntervalDS val1, OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the first of two OracleIntervalDS values is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

NotEquals

This static method determines whether or not two OracleIntervalDS values are not equal.

Declaration

// C#
public static bool NotEquals(OracleIntervalDS val1, OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if two OracleIntervalDS values are not equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

Parse

This static method returns an OracleIntervalDS instance and sets its value for time interval using a string.

Declaration

// C#
public static OracleIntervalDS Parse(string intervalStr);

Parameters

  • intervalStr

    A string representing the Oracle INTERVAL DAY TO SECOND.

Return Value

Returns an OracleIntervalDS instance representing the time interval from the supplied string.

Exceptions

ArgumentException - The intervalStr parameter is not in the valid format or intervalStr has an invalid value.

ArgumentNullException - The intervalStr parameter is null.

Remarks

The value specified in intervalStr must be in Day HH:MI:SSxFF format.

Example

"1 2:3:4.99" means 1 day, 2 hours, 3 minutes, 4 seconds, and 990 milliseconds or 1 day, 2 hours, 3 minutes, 4 seconds, and 990000000 nanoseconds.

SetPrecision

This static method returns a new instance of an OracleIntervalDS with the specified day precision and fractional second precision.

Declaration

// C#
public static OracleIntervalDS SetPrecision(OracleIntervalDS value1,
    int dayPrecision, int fracSecPrecision);

Parameters

  • value1

    An OracleIntervalDS structure.

  • dayPrecision

    The day precision provided. Range of day precision is (0 to 9).

  • fracSecPrecision

    The fractional second precision provided. Range of fractional second precision is (0 to 9).

Return Value

An OracleIntervalDS instance.

Exceptions

ArgumentOutOfRangeException - An argument value is out of the specified range.

Remarks

Depending on the value specified in the supplied dayPrecision, 0 or more leading zeros are displayed in the string returned by ToString().

The value specified in the supplied fracSecPrecision is used to perform a rounding off operation on the supplied OracleIntervalDS value. Depending on this value, 0 or more trailing zeros are displayed in the string returned by ToString().

Example

The OracleIntervalDS with a value of "1 2:3:4.99" results in the string "001 2:3:4.99000" when SetPrecision() is called, with the day precision set to 3 and fractional second precision set to 5.


OracleIntervalDS Static Operators

The OracleIntervalDS static operators are listed in Table 11-57.

Table 11-57 OracleIntervalDS Static Operators

Operator Description
operator + Adds two OracleIntervalDS values
operator == Determines whether or not two OracleIntervalDS values are equal
operator > Determines whether or not one OracleIntervalDS value is greater than another
operator >= Determines whether or not one OracleIntervalDS value is greater than or equal to another
operator != Determines whether or not two OracleIntervalDS values are not equal
operator < Determines whether or not one OracleIntervalDS value is less than another
operator <= Determines whether or not one OracleIntervalDS value is less than or equal to another
operator - Subtracts one OracleIntervalDS value from another
operator - Negates an OracleIntervalDS structure
operator * Multiplies an OracleIntervalDS value by a number
operator / Divides an OracleIntervalDS value by a number

operator +

This static operator adds two OracleIntervalDS values.

Declaration

// C#
public static OracleIntervalDS operator + (OracleIntervalDS val1,
   OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

An OracleIntervalDS.

Remarks

If either argument has a null value, the returned OracleIntervalDS structure has a null value.

operator ==

This static operator determines if two OracleIntervalDS values are equal.

Declaration

// C#
public static bool operator == (OracleIntervalDS val1,
    OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the two OracleIntervalDS values are the same; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

operator >

This static operator determines if the first of two OracleIntervalDS values is greater than the second.

Declaration

// C#
public static bool operator > (OracleIntervalDS val1,
   OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if one OracleIntervalDS value is greater than another; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

operator >=

This static operator determines if the first of two OracleIntervalDS values is greater than or equal to the second.

Declaration

// C#
public static bool operator >= (OracleIntervalDS val1, 
  OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the first of two OracleIntervalDS values is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

operator !=

This static operator determines if the two OracleIntervalDS values are not equal.

Declaration

// C#
public static bool operator != (OracleIntervalDS val1, 
  OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the two OracleIntervalDS values are not equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

operator <

This static operator determines if the first of two OracleIntervalDS values is less than the second.

Declaration

// C#
public static bool operator < (OracleIntervalDS val1, 
  OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the first of two OracleIntervalDS values is less than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

operator <=

This static operator determines if the first of two OracleIntervalDS values is less than or equal to the second.

Declaration

// C#
public static bool operator <= (OracleIntervalDS val1, 
   OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

Returns true if the first of two OracleIntervalDS values is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

operator -

This static operator subtracts one OracleIntervalDS structure from another.

Declaration

// C#
public static OracleIntervalDS operator - (OracleIntervalDS val1,
   OracleIntervalDS val2);

Parameters

  • val1

    The first OracleIntervalDS.

  • val2

    The second OracleIntervalDS.

Return Value

An OracleIntervalDS structure.

Remarks

If either argument has a null value, the returned OracleIntervalDS structure has a null value.

operator -

This static operator negates the supplied OracleIntervalDS structure.

Declaration

// C#
public static OracleIntervalDS operator - (OracleIntervalDS val);

Parameters

  • val

    An OracleIntervalDS.

Return Value

An OracleIntervalDS structure.

Remarks

If the supplied OracleIntervalDS structure has a null value, the returned OracleIntervalDS structure has a null value.

operator *

This static operator multiplies an OracleIntervalDS value by a number.

Declaration

// C#
public static OracleIntervalDS operator * (OracleIntervalDS val1, 
   int multiplier);

Parameters

  • val1

    The first OracleIntervalDS.

  • multiplier

    A multiplier.

Return Value

A new OracleIntervalDS instance.

Remarks

If the OracleIntervalDS structure has a null value, the returned OracleIntervalDS structure has a null value.

operator /

This static operator divides an OracleIntervalDS value by a number.

Declaration

// C#
public static OracleIntervalDS operator / (OracleIntervalDS val1, 
   int divisor);

Parameters

  • val1

    The first OracleIntervalDS.

  • divisor

    A divisor.

Return Value

An OracleIntervalDS structure.

Remarks

If the OracleIntervalDS structure has a null value, the returned OracleIntervalDS structure has a null value.


OracleIntervalDS Type Conversions

The OracleIntervalDS type conversions are listed in Table 11-58.

Table 11-58 OracleIntervalDS Type Conversions

Operator Description
explicit operator TimeSpan Converts an OracleIntervalDS structure to a TimeSpan structure
explicit operator OracleIntervalDS Converts a string to an OracleIntervalDS structure
implicit operator OracleIntervalDS Converts a TimeSpan structure to an OracleIntervalDS structure

explicit operator TimeSpan

This type conversion operator converts an OracleIntervalDS structure to a TimeSpan structure.

Declaration

// C#
public static explicit operator TimeSpan(OracleIntervalDS val);

Parameters

  • val

    An OracleIntervalDS instance.

Return Value

A TimeSpan structure.

Exceptions

OracleNullValueException - The OracleIntervalDS structure has a null value.

Remarks

explicit operator OracleIntervalDS

This type conversion operator converts a string to an OracleIntervalDS structure.

Declaration

// C#
public static explicit operator OracleIntervalDS (string intervalStr);

Parameters

  • intervalStr

    A string representation of an Oracle INTERVAL DAY TO SECOND.

Return Value

An OracleIntervalDS structure.

Exceptions

ArgumentException - The supplied intervalStr parameter is not in the correct format or has an invalid value.

ArgumentNullException - The intervalStr parameter is null.

Remarks

The returned OracleIntervalDS structure contains the same time interval represented by the supplied intervalStr. The value specified in the supplied intervalStr must be in Day HH:MI:SSxFF format.

Example

"1 2:3:4.99" means 1 day, 2 hours, 3 minutes 4 seconds and 990 milliseconds or 1 day, 2 hours, 3 minutes 4 seconds and 990000000 nanoseconds.

implicit operator OracleIntervalDS

This type conversion operator converts a TimeSpan structure to an OracleIntervalDS structure.

Declaration

// C#
public static implicit operator OracleIntervalDS(TimeSpan val);

Parameters

  • val

    A TimeSpan instance.

Return Value

An OracleIntervalDS structure.

Remarks

The returned OracleIntervalDS structure contains the same days, hours, seconds, and milliseconds as the supplied TimeSpan val.


OracleIntervalDS Properties

The OracleIntervalDS properties are listed in Table 11-59.

Table 11-59 OracleIntervalDS Properties

Properties Description
BinData Returns an array of bytes that represents the Oracle INTERVAL DAY TO SECOND in Oracle internal format
Days Gets the days component of an OracleIntervalDS
Hours Gets the hours component of an OracleIntervalDS
IsNull Indicates whether or not the current instance has a null value
Milliseconds Gets the milliseconds component of an OracleIntervalDS
Minutes Gets the minutes component of an OracleIntervalDS
Nanoseconds Gets the nanoseconds component of an OracleIntervalDS
Seconds Gets the seconds component of an OracleIntervalDS
TotalDays Returns the total number, in days, that represent the time period in the OracleIntervalDS structure
Value Specifies the time interval that is stored in the OracleIntervalDS structure

BinData

This property returns an array of bytes that represents the Oracle INTERVAL DAY TO SECOND in Oracle internal format.

Declaration

// C#
public byte[] BinData {get;}

Property Value

A byte array that represents an Oracle INTERVAL DAY TO SECOND in Oracle internal format.

Exceptions

OracleNullValueException - The current instance has a null value.

Remarks

Days

This property gets the days component of an OracleIntervalDS.

Declaration

// C#
public int Days {get;}

Property Value

An int representing the days component.

Exceptions

OracleNullValueException - The current instance has a null value.

Hours

This property gets the hours component of an OracleIntervalDS.

Declaration

// C#
public int Hours {get;}

Property Value

An int representing the hours component.

Exceptions

OracleNullValueException - The current instance has a null value.

IsNull

This property indicates whether or not the current instance has a null value.

Declaration

// C#
public bool IsNull {get;}

Property Value

Returns true if the current instance has a null value; otherwise, returns false.

Milliseconds

This property gets the milliseconds component of an OracleIntervalDS.

Declaration

// C#
public double Milliseconds {get;}

Property Value

A double that represents milliseconds component.

Exceptions

OracleNullValueException - The current instance has a null value.

Minutes

This property gets the minutes component of an OracleIntervalDS.

Declaration

// C#
public int Minutes {get;}

Property Value

A int that represents minutes component.

Exceptions

OracleNullValueException - The current instance has a null value.

Nanoseconds

This property gets the nanoseconds component of an OracleIntervalDS.

Declaration

// C#
public int Nanoseconds {get;}

Property Value

An int that represents nanoseconds component.

Exceptions

OracleNullValueException - The current instance has a null value.

Seconds

This property gets the seconds component of an OracleIntervalDS.

Declaration

// C#
public int Seconds {get;}

Property Value

An int that represents seconds component.

Exceptions

OracleNullValueException - The current instance has a null value.

TotalDays

This property returns the total number, in days, that represent the time period in the OracleIntervalDS structure.

Declaration

// C#
public double TotalDays {get;}

Property Value

A double that represents the total number of days.

Exceptions

OracleNullValueException - The current instance has a null value.

Value

This property specifies the time interval that is stored in the OracleIntervalDS structure.

Declaration

// C#
public TimeSpan Value {get;}

Property Value

A time interval.

Exceptions

OracleNullValueException - The current instance has a null value.


OracleIntervalDS Methods

The OracleIntervalDS methods are listed in Table 11-60.

Table 11-60 OracleIntervalDS Methods

Methods Description
CompareTo Compares the current OracleIntervalDS instance to an object, and returns an integer that represents their relative values
Equals Determines whether or not the specified object has the same time interval as the current instance (Overloaded)
GetHashCode Returns a hash code for the OracleIntervalDS instance
GetType Inherited from Object
ToString Converts the current OracleIntervalDS structure to a string

CompareTo

This method compares the current OracleIntervalDS instance to an object, and returns an integer that represents their relative values.

Declaration

// C#
public int CompareTo(object obj);

Parameters

  • obj

    The object being compared to.

Return Value

The method returns:

  • Less than zero: if the current OracleIntervalDS represents a shorter time interval than obj.

  • Zero: if the current OracleIntervalDS and obj represent the same time interval.

  • Greater than zero: if the current OracleIntervalDS represents a longer time interval than obj.

Implements

IComparable

Exceptions

ArgumentException - The obj parameter is not of type OracleIntervalDS.

Remarks

The following rules apply to the behavior of this method.

  • The comparison must be between OracleIntervalDSs. For example, comparing an OracleIntervalDS instance with an OracleBinary instance is not allowed. When an OracleIntervalDS is compared with a different type, an ArgumentException is thrown.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

Equals

This method determines whether or not the specified object has the same time interval as the current instance.

Declaration

// C#
public override bool Equals(object obj);

Parameters

  • obj

    The specified object.

Return Value

Returns true if obj is of type OracleIntervalDS and has the same time interval as the current instance; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleIntervalDS that has a value compares greater than an OracleIntervalDS that has a null value.

  • Two OracleIntervalDSs that contain a null value are equal.

GetHashCode

Overrides Object

This method returns a hash code for the OracleIntervalDS instance.

Declaration

// C#
public override int GetHashCode();

ToString

Overrides Object

This method converts the current OracleIntervalDS structure to a string.

Declaration

// C#
public override string ToString();

Return Value

Returns a string.

Remarks

If the current instance has a null value, the returned string contains "null".

PKuUQPKkUI(OEBPS/OracleParameterCollectionClass.htm Oracle Data Provider for .NET Classes

OracleParameterCollection Class

An OracleParameterCollection class represents a collection of all parameters relevant to an OracleCommand object and their mappings to DataSet columns.

Class Inheritance

Object

  MarshalByRefObject

    OracleParameterCollection

Declaration

// C#
public sealed class OracleParameterCollection : MarshalByRefObject, 
    IDataParameterCollection, IList, ICollection, IEnumerable

Thread Safety

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

Remarks

The position of an OracleParameter added into the OracleParameterCollection is the binding position in the SQL statement. Position is 0-based and is used only for positional binding. If named binding is used, the position of an OracleParameter in the OracleParameterCollection is ignored.

Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client; 
 
class OracleParameterCollectionSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    OracleParameter[] prm = new OracleParameter[3];
 
    // Create OracleParameter objects through OracleParameterCollection
    OracleCommand cmd = con.CreateCommand();
 
    cmd.CommandText = "select max(empno) from emp";
    int maxno = int.Parse(cmd.ExecuteScalar().ToString());
 
    prm[0] = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, 
      maxno + 10, ParameterDirection.Input);
    prm[1] = cmd.Parameters.Add("paramEname", OracleDbType.Varchar2, 
      "Client", ParameterDirection.Input);
    prm[2] = cmd.Parameters.Add("paramDeptNo", OracleDbType.Decimal, 
      10, ParameterDirection.Input);
    cmd.CommandText = 
      "insert into emp(empno, ename, deptno) values(:1, :2, :3)";
    cmd.ExecuteNonQuery();
 
    Console.WriteLine("Record for employee id {0} has been inserted.", 
      maxno + 10);
 
    // Remove all parameters from OracleParameterCollection
    cmd.Parameters.Clear();
 
    prm[0].Dispose();
    prm[1].Dispose();
    prm[2].Dispose();
    cmd.Dispose();
 
    con.Close();
    con.Dispose();
  }
}

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll


OracleParameterCollection Members

OracleParameterCollection members are listed in the following tables:

OracleParameterCollection Static Methods

OracleParameterCollection static methods are listed in Table 5-76.

Table 5-76 OracleParameterCollection Static Methods

Methods Description
Equals Inherited from Object (Overloaded)

OracleParameterCollection Properties

OracleParameterCollection properties are listed in Table 5-77.

Table 5-77 OracleParameterCollection Properties

Name Description
Count Specifies the number of OracleParameters in the collection
Item Gets and sets the OracleParameter object (Overloaded)

OracleParameterCollection Public Methods

OracleParameterCollection public methods are listed in Table 5-78.

Table 5-78 OracleParameterCollection Public Methods

Public Method Description
Add Adds objects to the collection (Overloaded)
Clear Removes all the OracleParameter objects from the collection
Contains Indicates whether or not objects exist in the collection (Overloaded)
CopyTo Copies OracleParameter objects from the collection, starting with the supplied index to the supplied array
CreateObjRef Inherited from MarshalByRefObject
Equals Inherited from Object (Overloaded)
GetHashCode Inherited from Object
GetLifetimeService Inherited from MarshalByRefObject
GetType Inherited from Object
InitializeLifetimeService Inherited from MarshalByRefObject
IndexOf Returns the index of the objects in the collection (Overloaded)
Insert Inserts the supplied OracleParameter to the collection at the specified index
Remove Removes objects from the collection
RemoveAt Removes objects from the collection by location (Overloaded)
ToString Inherited from Object


OracleParameterCollection Static Methods

The OracleParameterCollection static method is listed in Table 5-79.

Table 5-79 OracleParameterCollection Static Method

Method Description
Equals Inherited from Object (Overloaded)


OracleParameterCollection Properties

OracleParameterCollection properties are listed in Table 5-80.

Table 5-80 OracleParameterCollection Properties

Name Description
Count Specifies the number of OracleParameters in the collection
Item Gets and sets the OracleParameter object (Overloaded)

Count

This property specifies the number of OracleParameter objects in the collection.

Declaration

// C#
public int Count {get;}

Property Value

The number of OracleParameter objects.

Implements

ICollection

Remarks

Default = 0

Item

Item gets and sets the OracleParameter object.

Overload List:

  • Item[int]

    This property gets and sets the OracleParameter object at the index specified by the supplied parameterIndex.

  • Item[string]

    This property gets and sets the OracleParameter object using the parameter name specified by the supplied parameterName.

Item[int]

This property gets and sets the OracleParameter object at the index specified by the supplied parameterIndex.

Declaration

// C#
public object Item[int parameterIndex] {get; set;}

Property Value

An object.

Implements

IList

Exceptions

IndexOutOfRangeException - The supplied index does not exist.

Remarks

The OracleParameterCollection class is a zero-based index.

Item[string]

This property gets and sets the OracleParameter object using the parameter name specified by the supplied parameterName.

Declaration

// C#
public OracleParameter Item[string parameterName] {get; set;};

Property Value

An OracleParameter.

Implements

IDataParameterCollection

Exceptions

IndexOutOfRangeException - The supplied parameter name does not exist.


OracleParameterCollection Public Methods

OracleParameterCollection public methods are listed in Table 5-81.

Table 5-81 OracleParameterCollection Public Methods

Public Method Description
Add Adds objects to the collection (Overloaded)
Clear Removes all the OracleParameter objects from the collection
Contains Indicates whether or not objects exist in the collection (Overloaded)
CopyTo Copies OracleParameter objects from the collection, starting with the supplied index to the supplied array
CreateObjRef Inherited from MarshalByRefObject
Equals Inherited from Object (Overloaded)
GetHashCode Inherited from Object
GetLifetimeService Inherited from MarshalByRefObject
GetType Inherited from Object
InitializeLifetimeService Inherited from MarshalByRefObject
IndexOf Returns the index of the objects in the collection (Overloaded)
Insert Inserts the supplied OracleParameter to the collection at the specified index
Remove Removes objects from the collection
RemoveAt Removes objects from the collection by location (Overloaded)
ToString Inherited from Object

Add

Add adds objects to the collection.

Overload List:

Add(object)

This method adds the supplied object to the collection.

Declaration

// C#
public int Add(object obj);

Parameters

  • obj

    The supplied object.

Return Value

The index at which the new OracleParameter is added.

Implements

IList

Remarks

InvalidCastException - The supplied obj cannot be cast to an OracleParameter object.

Add(OracleParameter)

This method adds the supplied OracleParameter object to the collection.

Declaration

// C#
public OracleParameter Add(OracleParameter paramObj);

Parameters

  • paramObj

    The supplied OracleParameter object.

Return Value

The newly created OracleParameter object which was added to the collection.

Add(string, object)

This method adds an OracleParameter object to the collection using the supplied name and object value

Declaration

// C#
public OracleParameter Add(string name, object val);

Parameters

  • name

    The parameter name.

  • val

    The OracleParameter value.

Return Value

The newly created OracleParameter object which was added to the collection.

Add(string, OracleDbType)

This method adds an OracleParameter object to the collection using the supplied name and database type.

Declaration

// C#
public OracleParameter Add(string name, OracleDbType dbType);

Parameters

  • name

    The parameter name.

  • dbType

    The datatype of the OracleParameter.

Return Value

The newly created OracleParameter object which was added to the collection.

Add(string, OracleDbType, ParameterDirection)

This method adds an OracleParameter object to the collection using the supplied name, database type, and direction.

Declaration

// C#
public OracleParameter Add(string name, OracleDbType dbType,
   ParameterDirection direction);

Parameters

  • name

    The parameter name.

  • dbType

    The datatype of the OracleParameter.

  • direction

    The OracleParameter direction.

Return Value

The newly created OracleParameter object which was added to the collection.

Add(string, OracleDbType, object, ParameterDirection)

This method adds an OracleParameter object to the collection using the supplied name, database type, parameter value, and direction.

Declaration

// C#
public OracleParameter Add(string name, OracleDbType dbType, object val,
    ParameterDirection dir);

Parameters

  • name

    The parameter name.

  • dbType

    The datatype of the OracleParameter.

  • val

    The OracleParameter value.

  • dir

    The ParameterDirection value.

Return Value

The newly created OracleParameter object which was added to the collection.

Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client;
 
class AddSample
{
  static void Main()
  {
    OracleCommand cmd = new OracleCommand();
 
    // Add parameter to the OracleParameterCollection
    OracleParameter prm = cmd.Parameters.Add(
      "MyParam", OracleDbType.Decimal, 1, ParameterDirection.Input);
 
    // Prints "cmd.Parameters.Count = 1"
    Console.WriteLine("cmd.Parameters.Count = " + cmd.Parameters.Count);
 
    prm.Dispose();
    cmd.Dispose();
  }
}

Add(string, OracleDbType, int, object, ParameterDirection)

This method adds an OracleParameter object to the collection using the supplied name, database type, size, parameter value, and direction.

Declaration

// C#
public OracleParameter Add(string name, OracleDbType dbType, int size, 
    object val, ParameterDirection dir;

Parameters

  • name

    The parameter name.

  • dbType

    The datatype of the OracleParameter.

  • size

    The size of OracleParameter.

  • val

    The OracleParameter value.

  • dir

    The ParameterDirection value.

Return Value

The newly created OracleParameter object which was added to the collection.

Add(string, OracleDbType, int)

This method adds an OracleParameter object to the collection using the supplied name, database type, and size.

Declaration

// C#
public OracleParameter Add(string name, OracleDbType dbType, int size);

Parameters

  • name

    The parameter name.

  • dbType

    The datatype of the OracleParameter.

  • size

    The size of OracleParameter.

Return Value

The newly created OracleParameter object which was added to the collection.

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
 
class AddSample
{
  static void Main()
  {
    OracleCommand cmd = new OracleCommand();
 
    // Add parameter to the OracleParameterCollection
    OracleParameter prm = cmd.Parameters.Add(
      "MyParam", OracleDbType.Varchar2, 10);
 
    // Prints "cmd.Parameters.Count = 1"
    Console.WriteLine("cmd.Parameters.Count = " + cmd.Parameters.Count);
 
    prm.Dispose();
    cmd.Dispose();
  }
}

Add (string, OracleDbType, int, string)

This method adds an OracleParameter object to the collection using the supplied name, database type, size, and source column.

Declaration

// C#
public OracleParameter Add(string name, OracleDbType dbType, int size, 
    string srcColumn);

Parameters

  • name

    The parameter name.

  • dbType

    The datatype of the OracleParameter.

  • size

    The size of OracleParameter.

  • srcColumn

    The name of the source column.

Return Value

An OracleParameter.

Add(string, OracleDbType, int, ParameterDirection, bool, byte, byte, string, DataRowVersion, object)

This method adds an OracleParameter object to the collection using the supplied name, database type, size, direction, null indicator, precision, scale, source column, source version, and parameter value.

Declaration

// C#
public OracleParameter Add(string name, OracleDbType dbType, int size,
    ParameterDirection dir, bool isNullable, byte precision, 
    byte scale, string srcColumn, DataRowVersion version, object val);

Parameters

  • name

    The parameter name.

  • dbType

    The datatype of the OracleParameter.

  • size

    The size of OracleParameter.

  • dir

    The ParameterDirection value.

  • isNullable

    An indicator that specifies if the parameter value can be null.

  • precision

    The precision of the parameter value.

  • scale

    The scale of the parameter value.

  • srcColumn

    The name of the source column.

  • version

    The DataRowVersion value.

  • val

    The parameter value.

Return Value

The newly created OracleParameter object which was added to the collection.

Exceptions

ArgumentException - The type of supplied val does not belong to the type of Value property in any of the ODP.NET Types.

Clear

This method removes all the OracleParameter objects from the collection.

Declaration

// C#
public void Clear();

Implements

IList

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
 
class ClearSample
{
  static void Main()
  {
    OracleCommand cmd = new OracleCommand();
 
    // Add parameter to the OracleParameterCollection
    OracleParameter prm = cmd.Parameters.Add("MyParam", OracleDbType.Decimal);
 
    // Prints "cmd.Parameters.Count = 1"
    Console.WriteLine("cmd.Parameters.Count = " + cmd.Parameters.Count);
 
    // Clear all parameters in the OracleParameterCollection
    cmd.Parameters.Clear();
 
    // Prints "cmd.Parameters.Count = 0"
    Console.WriteLine("cmd.Parameters.Count = " + cmd.Parameters.Count);
 
    prm.Dispose();
    cmd.Dispose();
  }
}

Contains

Contains indicates whether or not the supplied object exists in the collection.

Overload List:

  • Contains(object)

    This method indicates whether or not the supplied object exists in the collection.

  • Contains(string)

    This method indicates whether or not an OracleParameter object exists in the collection using the supplied string.

Contains(object)

This method indicates whether or not the supplied object exists in the collection.

Declaration

// C#
public bool Contains(object obj)

Parameters

  • obj

    The object.

Return Value

A bool that indicates whether or not the OracleParameter specified is inside the collection.

Implements

IList

Exceptions

InvalidCastException - The supplied obj is not an OracleParameter object.

Remarks

Returns true if the collection contains the OracleParameter object; otherwise, returns false.

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
 
class ContainsSample
{
  static void Main()
  {
    OracleCommand cmd = new OracleCommand();
 
    // Add parameter to the OracleParameterCollection
    OracleParameter prm1 = cmd.Parameters.Add("MyParam", OracleDbType.Decimal);
 
    // Check if the OracleParameterCollection contains prm1
    bool bContains = cmd.Parameters.Contains(prm1);
 
    // Prints "bContains = True"
    Console.WriteLine("bContains = " + bContains);
 
    OracleParameter prm2 = new OracleParameter();
 
    // Check if the OracleParameterCollection contains prm2
    bContains = cmd.Parameters.Contains(prm2);
 
    // Prints "bContains = False"
    Console.WriteLine("bContains = " + bContains);
 
    prm1.Dispose();
    prm2.Dispose();
    cmd.Dispose();
  }
}

Contains(string)

This method indicates whether or not an OracleParameter object exists in the collection using the supplied string.

Declaration

// C#
public bool Contains(string name);

Parameters

  • name

    The name of OracleParameter object.

Return Value

Returns true if the collection contains the OracleParameter object with the specified parameter name; otherwise, returns false.

Implements

IDataParameterCollection

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
 
class ContainsSample
{
  static void Main()
  {
    OracleCommand cmd = new OracleCommand();
 
    // Add parameter to the OracleParameterCollection
    OracleParameter prm = cmd.Parameters.Add("MyParam", OracleDbType.Decimal);
 
    // Check if the OracleParameterCollection contains "MyParam"
    bool bContains = cmd.Parameters.Contains("MyParam");
 
    // Prints "bContains = True"
    Console.WriteLine("bContains = " + bContains);
 
    // Check if the OracleParameterCollection contains "NoParam"
    bContains = cmd.Parameters.Contains("NoParam");
 
    // Prints "bContains = False"
    Console.WriteLine("bContains = " + bContains);
 
    prm.Dispose();
    cmd.Dispose();
  }
}

CopyTo

This method copies OracleParameter objects from the collection, starting with the supplied index to the supplied array.

Declaration

// C#
public void CopyTo(Array array, int index);

Parameters

  • array

    The specified array.

  • index

    The array index.

Implements

ICollection

IndexOf

IndexOf returns the index of the OracleParameter object in the collection.

Overload List:

  • IndexOf(object)

    This method returns the index of the OracleParameter object in the collection.

  • IndexOf(String)

    This method returns the index of the OracleParameter object with the specified name in the collection.

IndexOf(object)

This method returns the index of the OracleParameter object in the collection.

Declaration

// C#
public int IndexOf(object obj);

Parameters

  • obj

    The specified object.

Return Value

Returns the index of the OracleParameter object in the collection.

Implements

IList

Exceptions

InvalidCastException - The supplied obj cannot be cast to an OracleParameter object.

Remarks

Returns the index of the supplied OracleParameter obj in the collection.

IndexOf(String)

This method returns the index of the OracleParameter object with the specified name in the collection.

Declaration

// C#
public int IndexOf(String name);

Parameters

    n%
  • name

    The name of parameter.

Return Value

Returns the index of the supplied OracleParameter in the collection.

Implements

IDataParameterCollection

Insert

This method inserts the supplied OracleParameter object to the collection at the specified index.

Declaration

// C#
public void Insert(int index, object obj);

Parameters

  • index

    The specified index.

  • obj

    The OracleParameter object.

Implements

IList

Remarks

An InvalidCastException is thrown if the supplied obj cannot be cast to an OracleParameter object.

Remove

This method removes the supplied OracleParameter from the collection.

Declaration

// C#
public void Remove(object obj);

Parameters

  • obj

    The specified object to remove.

Implements

IList

Exceptions

InvalidCastException - The supplied obj cannot be cast to an OracleParameter object.

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
 
class RemoveSample
{
  static void Main()
  {
    OracleCommand cmd = new OracleCommand();
 
    // Add 2 parameters to the OracleParameterCollection
    OracleParameter prm1 = cmd.Parameters.Add("MyParam1", OracleDbType.Decimal);
    OracleParameter prm2 = cmd.Parameters.Add("MyParam2", OracleDbType.Decimal);
 
    // Prints "cmd.Parameters.Count = 2"
    Console.WriteLine("cmd.Parameters.Count = " + cmd.Parameters.Count);
 
    // Remove the 1st parameter from the OracleParameterCollection
    cmd.Parameters.Remove(prm1);
 
    // Prints "cmd.Parameters.Count = 1"
    Console.WriteLine("cmd.Parameters.Count = " + cmd.Parameters.Count);
 
    // Prints "cmd.Parameters[0].ParameterName = MyParam2"
    Console.WriteLine("cmd.Parameters[0].ParameterName = " + 
      cmd.Parameters[0].ParameterName);
 
    prm1.Dispose();
    prm2.Dispose();
    cmd.Dispose();
  }
}

RemoveAt

RemoveAt removes the OracleParameter object from the collection by location.

Overload List:

  • RemoveAt(int)

    This method removes from the collection the OracleParameter object located at the index specified by the supplied index.

  • RemoveAt(String)

    This method removes from the collection the OracleParameter object specified by the supplied name.

RemoveAt(int)

This method removes from the collection the OracleParameter object located at the index specified by the supplied index.

Declaration

// C#
public void RemoveAt(int index);

Parameters

  • index

    The specified index from which the OracleParameter is to be removed.

Implements

IList

RemoveAt(String)

This method removes from the collection the OracleParameter object specified by the supplied name.

Declaration

// C#
public void RemoveAt(String name);

Parameters

  • name

    The name of the OracleParameter object to be removed from the collection.

Implements

IDataParameterCollection

PKC}%n%PKkUIOEBPS/xmlclass.htmG Oracle Data Provider for .NET XML-Related Classes

6 Oracle Data Provider for .NET XML-Related Classes

This chapter describes ODP.NET XML-related classes and enumerations.

This chapter contains these topics:

All offsets are 0-based for OracleXmlStream object parameters.

PKjܽPKkUI"OEBPS/OracleTimeStampStructure.htm Oracle Data Provider for .NET Types Structures

OracleTimeStamp Structure

The OracleTimeStamp structure represents the Oracle TIMESTAMP datatype to be stored in or retrieved from a database. Each OracleTimeStamp stores the following information: year, month, day, hour, minute, second, and nanosecond.

Class Inheritance

Object

  ValueType

    OracleTimeStamp

Declaration

// C#
public struct OracleTimeStamp : IComparable

Thread Safety

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

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
 
class OracleTimeStampSample
{
  static void Main()
  {
    OracleTimeStamp tsCurrent1 = OracleTimeStamp.GetSysDate();
    OracleTimeStamp tsCurrent2 = DateTime.Now;
    
    // Calculate the difference between tsCurrent1 and tsCurrent2
    OracleIntervalDS idsDiff = tsCurrent2.GetDaysBetween(tsCurrent1);
    
    // Calculate the difference using AddNanoseconds()
    int nanoDiff = 0;
    while (tsCurrent2 > tsCurrent1)
    {
      nanoDiff += 10;
      tsCurrent1 = tsCurrent1.AddNanoseconds(10);
    }
    Console.WriteLine("idsDiff.Nanoseconds = " + idsDiff.Nanoseconds);
    Console.WriteLine("nanoDiff = " + nanoDiff);
  }
}

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll


OracleTimeStamp Members

OracleTimeStamp members are listed in the following tables:

OracleTimeStamp Constructors

OracleTimeStamp constructors are listed in Table 11-87

Table 11-87 OracleTimeStamp Constructors

Constructor Description
OracleTimeStamp Constructors Instantiates a new instance of OracleTimeStamp structure (Overloaded)

OracleTimeStamp Static Fields

The OracleTimeStamp static fields are listed in Table 11-88.

Table 11-88 OracleTimeStamp Static Fields

Field Description
MaxValue Represents the maximum valid date for an OracleTimeStamp structure, which is December 31, 9999 23:59:59.999999999
MinValue Represents the minimum valid date for an OracleTimeStamp structure, which is January 1, -4712 0:0:0
Null Represents a null value that can be assigned to an instance of the OracleTimeStamp structure

OracleTimeStamp Static Methods

The OracleTimeStamp static methods are listed in Table 11-89.

Table 11-89 OracleTimeStamp Static Methods

Methods Description
Equals Determines if two OracleTimeStamp values are equal (Overloaded)
GreaterThan Determines if the first of two OracleTimeStamp values is greater than the second
GreaterThanOrEqual Determines if the first of two OracleTimeStamp values is greater than or equal to the second
LessThan Determines if the first of two OracleTimeStamp values is less than the second
LessThanOrEqual Determines if the first of two OracleTimeStamp values is less than or equal to the second
NotEquals Determines if two OracleTimeStamp values are not equal
GetSysDate Gets an OracleTimeStamp structure that represents the current date and time
Parse Gets an OracleTimeStamp structure and sets its value using the supplied string
SetPrecision Returns a new instance of an OracleTimeStamp with the specified fractional second precision

OracleTimeStamp Static Operators

The OracleTimeStamp static operators are listed in Table 11-90.

Table 11-90 OracleTimeStamp Static Operators

Operator Description
operator + Adds the supplied instance value to the supplied OracleTimeStamp and returns a new OracleTimeStamp structure (Overloaded)
operator == Determines if two OracleTimeStamp values are equal
operator > Determines if the first of two OracleTimeStamp values is greater than the second
operator >= Determines if the first of two OracleTimeStamp values is greater than or equal to the second
operator != Determines if the two OracleTimeStamp values are not equal
operator < Determines if the first of two OracleTimeStamp values is less than the second
operator <= Determines if the first of two OracleTimeStamp values is less than or equal to the second
operator - Subtracts the supplied instance value from the supplied OracleTimeStamp and returns a new OracleTimeStamp structure (Overloaded)

OracleTimeStamp Static Type Conversions

The OracleTimeStamp static type conversions are listed in Table 11-91.

Table 11-91 OracleTimeStamp Static Type Conversions

Operator Description
explicit operator OracleTimeStamp Converts an instance value to an OracleTimeStamp structure (Overloaded)
implicit operator OracleTimeStamp Converts an instance value to an OracleTimeStamp structure (Overloaded)
explicit operator DateTime Converts an OracleTimeStamp value to a DateTime structure

OracleTimeStamp Properties

The OracleTimeStamp properties are listed in Table 11-92.

Table 11-92 OracleTimeStamp Properties

Properties Description
BinData Returns an array of bytes that represents an Oracle TIMESTAMP in Oracle internal format
Day Specifies the day component of an OracleTimeStamp
IsNull Indicates whether or not the OracleTimeStamp instance has a null value
Hour Specifies the hour component of an OracleTimeStamp
Millisecond Specifies the millisecond component of an OracleTimeStamp
Minute Specifies the minute component of an OracleTimeStamp
Month Specifies the month component of an OracleTimeStamp
Nanosecond Specifies the nanosecond component of an OracleTimeStamp
Second Specifies the second component of an OracleTimeStamp
Value Specifies the date and time that is stored in the OracleTimeStamp structure
Year Specifies the year component of an OracleTimeStamp

OracleTimeStamp Methods

The OracleTimeStamp methods are listed in Table 11-93.

Table 11-93 OracleTimeStamp Methods

Methods Description
AddDays Adds the supplied number of days to the current instance
AddHours Adds the supplied number of hours to the current instance
AddMilliseconds Adds the supplied number of milliseconds to the current instance
AddMinutes Adds the supplied number of minutes to the current instance
AddMonths Adds the supplied number of months to the current instance
AddNanoseconds Adds the supplied number of nanoseconds to the current instance
AddSeconds Adds the supplied number of seconds to the current instance
AddYears Adds the supplied number of years to the current instance
CompareTo Compares the current OracleTimeStamp instance to an object, and returns an integer that represents their relative values
Equals Determines whether or not an object has the same date and time as the current OracleTimeStamp instance (Overloaded)
GetHashCode Returns a hash code for the OracleTimeStamp instance
GetDaysBetween Subtracts an OracleTimeStamp value from the current instance and returns an OracleIntervalDS that represents the time difference between the supplied OracleTimeStamp and the current instance
GetYearsBetween Subtracts value1 from the current instance and returns an OracleIntervalYM that represents the difference between value1 and the current instance using OracleIntervalYM
GetType Inherited from Object
ToOracleDate Converts the current OracleTimeStamp structure to an OracleDate structure
ToOracleTimeStampLTZ Converts the current OracleTimeStamp structure to an OracleTimeStampLTZ structure
ToOracleTimeStampTZ Converts the current OracleTimeStamp structure to an OracleTimeStampTZ structure
ToString Converts the current OracleTimeStamp structure to a string


OracleTimeStamp Constructors

The OracleTimeStamp constructors create new instances of the OracleTimeStamp structure.

Overload List:

  • OracleTimeStamp(DateTime)

    This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using the supplied DateTime value.

  • OracleTimeStamp(string)

    This constructor creates a new instance of the OracleTimeStamp structure and sets its value using the supplied string.

  • OracleTimeStamp(int, int, int)

    This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date using year, month, and day.

  • OracleTimeStamp(int, int, int, int, int, int)

    This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using year, month, day, hour, minute, and second.

  • OracleTimeStamp(int, int, int, int, int, int, double)

    This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using year, month, day, hour, minute, second, and millisecond.

  • OracleTimeStamp(int, int, int, int, int, int, int)

    This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using year, month, day, hour, minute, second, and nanosecond.

  • OracleTimeStamp(byte [ ])

    This constructor creates a new instance of the OracleTimeStamp structure and sets its value to the provided byte array, which is in the internal Oracle TIMESTAMP format.

OracleTimeStamp(DateTime)

This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using the supplied DateTime value.

Declaration

// C#
public OracleTimeStamp (DateTime dt);

Parameters

  • dt

    The supplied DateTime value.

Exceptions

ArgumentException - The dt parameter cannot be used to construct a valid OracleTimeStamp.

OracleTimeStamp(string)

This constructor creates a new instance of the OracleTimeStamp structure and sets its value using the supplied string.

Declaration

// C#
public OracleTimeStamp (string tsStr);

Parameters

  • tsStr

    A string that represents an Oracle TIMESTAMP.

Exceptions

ArgumentException - The tsStr value is an invalid string representation of an Oracle TIMESTAMP or the supplied tsStr is not in the timestamp format specified by the OracleGlobalization.TimeStampFormat property of the thread, which represents the Oracle NLS_TIMESTAMP_FORMAT parameter.

ArgumentNullException - The tsStr value is null.

Remarks

The names and abbreviations used for months and days are in the language specified by the DateLanguage and Calendar properties of the thread's OracleGlobalization object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
 
class OracleTimeStampSample
{
  static void Main()
  {
    // Set the nls_timestamp_format for the OracleTimeStamp(string) 
    // constructor
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
    
    // construct OracleTimeStamp from a string using the format specified.
    OracleTimeStamp ts = new OracleTimeStamp("11-NOV-1999 11:02:33.444 AM");
    
    // Set the nls_timestamp_format for the ToString() method
    info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
 
    // Prints "1999-NOV-11 11:02:33.444000000 AM"
    Console.WriteLine(ts.ToString());    
  }
}

OracleTimeStamp(int, int, int)

This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date using year, month, and day.

Declaration

// C#
public OracleTimeStamp(int year, int month, int day);

Parameters

  • year

    The year provided. Range of year is (-4712 to 9999).

  • month

    The month provided. Range of month is (1 to 12).

  • day

    The day provided. Range of day is (1 to 31).

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleTimeStamp (that is, the day is out of range for the month).

OracleTimeStamp(int, int, int, int, int, int)

This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using year, month, day, hour, minute, and second.

Declaration

// C#
public OracleTimeStamp (int year, int month, int day, int hour, 
  int minute, int second);
  

Parameters

  • year

    The year provided. Range of year is (-4712 to 9999).

  • month

    The month provided. Range of month is (1 to 12).

  • day

    The day provided. Range of day is (1 to 31).

  • hour

    The hour provided. Range of hour is (0 to 23).

  • minute

    The minute provided. Range of minute is (0 to 59).

  • second

    The second provided. Range of second is (0 to 59).

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleTimeStamp (that is, the day is out of range for the month).

OracleTimeStamp(int, int, int, int, int, int, double)

This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using year, month, day, hour, minute, second, and millisecond.

Declaration

// C#
public OracleTimeStamp(int year, int month, int day, int hour,
   int minute,  int second, double millisecond);
 

Parameters

  • year

    The year provided. Range of year is (-4712 to 9999).

  • month

    The month provided. Range of month is (1 to 12).

  • day

    The day provided. Range of day is (1 to 31).

  • hour

    The hour provided. Range of hour is (0 to 23).

  • minute

    The minute provided. Range of minute is (0 to 59).

  • second

    The second provided. Range of second is (0 to 59).

  • milliSeconds

    The milliseconds provided. Range of millisecond is (0 to 999.999999).

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleTimeStamp (that is, the day is out of range for the month).

OracleTimeStamp(int, int, int, int, int, int, int)

This constructor creates a new instance of the OracleTimeStamp structure and sets its value for date and time using year, month, day, hour, minute, second, and nanosecond.

Declaration

// C#
public OracleTimeStamp (int year, int month, int day, int hour, 
   int minute, int second, int nanosecond);
   

Parameters

  • year

    The year provided. Range of year is (-4712 to 9999).

  • month

    The month provided. Range of month is (1 to 12).

  • day

    The day provided. Range of day is (1 to 31).

  • hour

    The hour provided. Range of hour is (0 to 23).

  • minute

    The minute provided. Range of minute is (0 to 59).

  • second

    The second provided. Range of second is (0 to 59).

  • nanosecond

    The nanosecond provided. Range of nanosecond is (0 to 999999999).

Exceptions

ArgumentOutOfRangeException - The argument value for one or more of the parameters is out of the specified range.

ArgumentException - The argument values of the parameters cannot be used to construct a valid OracleTimeStamp (that is, the day is out of range for the month).

OracleTimeStamp(byte [ ])

This constructor creates a new instance of the OracleTimeStamp structure and sets its value to the provided byte array, which is in the internal Oracle TIMESTAMP format.

Declaration

// C#
public OracleTimeStamp (byte[] bytes);

Parameters

  • bytes

    A byte array that represents an Oracle TIMESTAMP in Oracle internal format.

Exceptions

ArgumentException - bytes is not in an internal Oracle TIMESTAMP format or bytes is not a valid Oracle TIMESTAMP.

ArgumentNullException - bytes is null.


OracleTimeStamp Static Fields

The OracleTimeStamp static fields are listed in Table 11-94.

Table 11-94 OracleTimeStamp Static Fields

Field Description
MaxValue Represents the maximum valid date for an OracleTimeStamp structure, which is December 31, 9999 23:59:59.999999999
MinValue Represents the minimum valid date for an OracleTimeStamp structure, which is January 1, -4712 0:0:0
Null Represents a null value that can be assigned to an instance of the OracleTimeStamp structure

MaxValue

This static field represents the maximum valid date and time for an OracleTimeStamp structure, which is December 31, 9999 23:59:59.999999999.

Declaration

// C#
public static readonly OraTimestamp MaxValue;

MinValue

This static field represents the minimum valid date and time for an OracleTimeStamp structure, which is January 1, -4712 0:0:0.

Declaration

// C#
public static readonly OracleTimeStamp MinValue;

Null

This static field represents a null value that can be assigned to an instance of the OracleTimeStamp structure.

Declaration

// C#
public static readonly OracleTimeStamp Null;

OracleTimeStamp Static Methods

The OracleTimeStamp static methods are listed in Table 11-95.

Table 11-95 OracleTimeStamp Static Methods

Methods Description
Equals Determines if two OracleTimeStamp values are equal (Overloaded)
GreaterThan Determines if the first of two OracleTimeStamp values is greater than the second
GreaterThanOrEqual Determines if the first of two OracleTimeStamp values is greater than or equal to the second
LessThan Determines if the first of two OracleTimeStamp values is less than the second
LessThanOrEqual Determines if the first of two OracleTimeStamp values is less than or equal to the second
NotEquals Determines if two OracleTimeStamp values are not equal
GetSysDate Gets an OracleTimeStamp structure that represents the current date and time
Parse Gets an OracleTimeStamp structure and sets its value using the supplied string
SetPrecision Returns a new instance of an OracleTimeStamp with the specified fractional second precision

Equals

This static method determines if two OracleTimeStamp values are equal.

Declaration

// C#
public static bool Equals(OracleTimeStamp value1, OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if two OracleTimeStamp values are equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

GreaterThan

This static method determines if the first of two OracleTimeStamp values is greater than the second.

Declaration

// C#
public static bool GreaterThan(OracleTimeStamp value1, 
   OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first of two OracleTimeStamp values is greater than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

GreaterThanOrEqual

This static method determines if the first of two OracleTimeStamp values is greater than or equal to the second.

Declaration

// C#
public static bool GreaterThanOrEqual(OracleTimeStamp value1, 
     OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first of two OracleTimeStamp values is greater than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

LessThan

This static method determines if the first of two OracleTimeStamp values is less than the second.

Declaration

// C#
public static bool LessThan(OracleTimeStamp value1, 
   OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first of two OracleTimeStamp values is less than the second. Returns false otherwise.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

LessThanOrEqual

This static method determines if the first of two OracleTimeStamp values is less than or equal to the second.

Declaration

// C#
public static bool LessThanOrEqual(OracleTimeStamp value1, 
     OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first of two OracleTimeStamp values is less than or equal to the second. Returns false otherwise.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

NotEquals

This static method determines if two OracleTimeStamp values are not equal.

Declaration

// C#
public static bool NotEquals(OracleTimeStamp value1, 
   OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if two OracleTimeStamp values are not equal. Returns false otherwise.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

GetSysDate

This static method gets an OracleTimeStamp structure that represents the current date and time.

Declaration

// C#
public static OracleTimeStamp GetSysDate();

Return Value

An OracleTimeStamp structure that represents the current date and time.

Parse

This static method gets an OracleTimeStamp structure and sets its value using the supplied string.

Declaration

// C#
public static OracleTimeStamp Parse(string datetime);

Parameters

  • datetime

    A string that represents an Oracle TIMESTAMP.

Return Value

An OracleTimeStamp structure.

Exceptions

ArgumentException - The tsStr is an invalid string representation of an Oracle TIMESTAMP or the supplied tsStr is not in the timestamp format specified by the OracleGlobalization.TimeStampFormat property of the thread, which represents the Oracle NLS_TIMESTAMP_FORMAT parameter.

ArgumentNullException - The tsStr value is null.

Remarks

The names and abbreviations used for months and days are in the language specified by the DateLanguage and Calendar properties of the thread's OracleGlobalization object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
 
class ParseSample
{
  static void Main()
  {
    // Set the nls_timestamp_format for the Parse() method
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
    
    // construct OracleTimeStamp from a string using the format specified.
    OracleTimeStamp ts = 
      OracleTimeStamp.Parse("11-NOV-1999 11:02:33.444 AM");
      
    // Set the nls_timestamp_format for the ToString() method
    info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
 
    // Prints "1999-NOV-11 11:02:33.444000000 AM"
    Console.WriteLine(ts.ToString());    
  }
}

SetPrecision

This static method returns a new instance of an OracleTimeStamp with the specified fractional second precision.

Declaration

// C#
public static OracleTimeStamp SetPrecision(OracleTimeStamp value1,
    int fracSecPrecision);

Parameters

  • value1

    The provided OracleTimeStamp object.

  • fracSecPrecision

    The fractional second precision provided. Range of fractional second precision is (0 to 9).

Return Value

An OracleTimeStamp structure with the specified fractional second precision.

Exceptions

ArgumentOutOfRangeException - fracSecPrecision is out of the specified range.

Remarks

The value specified in the supplied fracSecPrecision is used to perform a rounding off operation on the supplied OracleTimeStamp value. Depending on this value, 0 or more trailing zeros are displayed in the string returned by ToString().

Example

The OracleTimeStamp with a value of "December 31, 9999 23:59:59.99" results in the string "December 31, 9999 23:59:59.99000" when SetPrecision() is called with the fractional second precision set to 5.


OracleTimeStamp Static Operators

The OracleTimeStamp static operators are listed in Table 11-96.

Table 11-96 OracleTimeStamp Static Operators

Operator Description
operator +
Adds the supplied instance value to the supplied OracleTimeStamp and returns a new OracleTimeStamp structure (Overloaded)
operator ==
Determines if two OracleTimeStamp values are equal
operator >
Determines if the first of two OracleTimeStamp values is greater than the second
operator >=
Determines if the first of two OracleTimeStamp values is greater than or equal to the second
operator != Determines if the two OracleTimeStamp values are not equal
operator < Determines if the first of two OracleTimeStamp values is less than the second
operator <= Determines if the first of two OracleTimeStamp values is less than or equal to the second
operator -
Subtracts the supplied instance value from the supplied OracleTimeStamp and returns a new OracleTimeStamp structure (Overloaded)

operator +

operator+ adds the supplied object to the OracleTimeStamp and returns a new OracleTimeStamp structure.

Overload List:

operator + (OracleTimeStamp, OracleIntervalDS)

This static operator adds the supplied OracleIntervalDS to the OracleTimeStamp and returns a new OracleTimeStamp structure.

Declaration

// C#
public static operator + (OracleTimeStamp value1, OracleIntervalDS value2);

Parameters

  • value1

    An OracleTimeStamp.

  • value2

    An OracleIntervalDS.

Return Value

An OracleTimeStamp.

Remarks

If either parameter has a null value, the returned OracleTimeStamp has a null value.

operator + (OracleTimeStamp, OracleIntervalYM)

This static operator adds the supplied OracleIntervalYM to the supplied OracleTimeStamp and returns a new OracleTimeStamp structure.

Declaration

// C#
public static operator + (OracleTimeStamp value1, OracleIntervalYM value2);

Parameters

  • value1

    An OracleTimeStamp.

  • value2

    An OracleIntervalYM.

Return Value

An OracleTimeStamp.

Remarks

If either parameter has a null value, the returned OracleTimeStamp has a null value.

operator + (OracleTimeStamp, TimeSpan)

This static operator adds the supplied TimeSpan to the supplied OracleTimeStamp and returns a new OracleTimeStamp structure.

Declaration

// C#
public static operator + (OracleTimeStamp value1, TimeSpan value2);

Parameters

  • value1

    An OracleTimeStamp.

  • value2

    A TimeSpan.

Return Value

An OracleTimeStamp.

Remarks

If the OracleTimeStamp instance has a null value, the returned OracleTimeStamp has a null value.

operator ==

This static operator determines if two OracleTimeStamp values are equal.

Declaration

// C#
public static bool operator == (OracleTimeStamp value1,
   OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if they are the same; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

operator >

This static operator determines if the first of two OracleTimeStamp values is greater than the second.

Declaration

// C#
public static bool operator > (OracleTimeStamp value1, 
   OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first OracleTimeStamp value is greater than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

operator >=

This static operator determines if the first of two OracleTimeStamp values is greater than or equal to the second.

Declaration

// C#
public static bool operator >= (OracleTimeStamp value1, 
  OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first OracleTimeStamp is greater than or equal to the second; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

operator !=

This static operator determines if two OracleTimeStamp values are not equal.

Declaration

// C#
public static bool operator != (OracleTimeStamp value1, 
  OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if two OracleTimeStamp values are not equal; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

operator <

This static operator determines if the first of two OracleTimeStamp values is less than the second.

Declaration

// C#
public static bool operator < (OracleTimeStamp value1, 
  OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first OracleTimeStamp is less than the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

operator <=

This static operator determines if the first of two OracleTimeStamp values is less than or equal to the second.

Declaration

// C#
public static bool operator <= (OracleTimeStamp value1, 
  OracleTimeStamp value2);

Parameters

  • value1

    The first OracleTimeStamp.

  • value2

    The second OracleTimeStamp.

Return Value

Returns true if the first OracleTimeStamp is less than or equal to the second; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

operator -

operator- subtracts the supplied value, from the supplied OracleTimeStamp value, and returns a new OracleTimeStamp structure.

Overload List:

operator - (OracleTimeStamp, OracleIntervalDS)

This static operator subtracts the supplied OracleIntervalDS value, from the supplied OracleTimeStamp value, and return a new OracleTimeStamp structure.

Declaration

// C#
public static operator - (OracleTimeStamp value1, OracleIntervalDS value2);

Parameters

  • value1

    An OracleTimeStamp.

  • value2

    An OracleIntervalDS instance.

Return Value

An OracleTimeStamp structure.

Remarks

If either parameter has a null value, the returned OracleTimeStamp has a null value.

operator - (OracleTimeStamp, OracleIntervalYM)

This static operator subtracts the supplied OracleIntervalYM value, from the supplied OracleTimeStamp value, and returns a new OracleTimeStamp structure.

Declaration

// C#
public static operator - (OracleTimeStamp value1, OracleIntervalYM value2);

Parameters

  • value1

    An OracleTimeStamp.

  • value2

    An OracleIntervalYM instance.

Return Value

An OracleTimeStamp structure.

Remarks

If either parameter has a null value, the returned OracleTimeStamp has a null value.

operator - (OracleTimeStamp, TimeSpan)

This static operator subtracts the supplied TimeSpan value, from the supplied OracleTimeStamp value, and returns a new OracleTimeStamp structure.

Declaration

// C#
public static operator - (OracleTimeStamp value1, TimeSpan value2);

Parameters

  • value1

    An OracleTimeStamp.

  • value2

    A TimeSpan instance.

Return Value

An OracleTimeStamp structure.

Remarks

If the OracleTimeStamp instance has a null value, the returned OracleTimeStamp structure has a null value.


OracleTimeStamp Static Type Conversions

The OracleTimeStamp static type conversions are listed in Table 11-97.

Table 11-97 OracleTimeStamp Static Type Conversions

Operator Description
explicit operator OracleTimeStamp Converts an instance value to an OracleTimeStamp structure (Overloaded)
implicit operator OracleTimeStamp Converts an instance value to an OracleTimeStamp structure (Overloaded)
explicit operator DateTime Converts an OracleTimeStamp value to a DateTime structure

explicit operator OracleTimeStamp

explicit operator OracleTimeStamp converts the supplied value to an OracleTimeStamp structure

Overload List:

explicit operator OracleTimeStamp(OracleTimeStampLTZ)

This static type conversion operator converts an OracleTimeStampLTZ value to an OracleTimeStamp structure.

Declaration

// C#
public static explicit operator OracleTimeStamp(OracleTimeStampLTZ value1);

Parameters

  • value1

    An OracleTimeStampLTZ instance.

Return Value

The returned OracleTimeStamp contains the date and time of the OracleTimeStampLTZ structure.

Remarks

If the OracleTimeStampLTZ structure has a null value, the returned OracleTimeStamp structure also has a null value.

explicit operator OracleTimeStamp(OracleTimeStampTZ)

This static type conversion operator converts an OracleTimeStampTZ value to an OracleTimeStamp structure.

Declaration

// C#
public static explicit operator OracleTimeStamp(OracleTimeStampTZ value1);

Parameters

  • value1

    An OracleTimeStampTZ instance.

Return Value

The returned OracleTimeStamp contains the date and time information from value1, but the time zone information from value1 is truncated.

Remarks

If the OracleTimeStampTZ structure has a null value, the returned OracleTimeStamp structure also has a null value.

explicit operator OracleTimeStamp(string)

This static type conversion operator converts the supplied string to an OracleTimeStamp structure.

Declaration

// C#
public static explicit operator OracleTimeStamp(string tsStr);

Parameters

  • tsStr

    A string representation of an Oracle TIMESTAMP.

Return Value

An OracleTimeStamp.

Exceptions

ArgumentException - The tsStr is an invalid string representation of an Oracle TIMESTAMP or the tsStr is not in the timestamp format specified by the thread's OracleGlobalization.TimeStampFormat property, which represents the Oracle NLS_TIMESTAMP_FORMAT parameter.

Remarks

The names and abbreviations used for months and days are in the language specified by the DateLanguage and Calendar properties of the thread's OracleGlobalization object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
 
class OracleTimeStampSample
{
  static void Main()
  {
    // Set the nls_timestamp_format for the explicit
    // operator OracleTimeStamp(string)
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
    
    // construct OracleTimeStamp from a string using the format specified.
    OracleTimeStamp ts = new OracleTimeStamp("11-NOV-1999 11:02:33.444 AM");
    
    // Set the nls_timestamp_format for the ToString method
    info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
 
    // Prints "1999-NOV-11 11:02:33.444000000 AM"   
    Console.WriteLine(ts.ToString());    
  }
}

implicit operator OracleTimeStamp

This static type conversion operator converts a value to an OracleTimeStamp structure.

Overload List:

implicit operator OracleTimeStamp(OracleDate)

This static type conversion operator converts an OracleDate value to an OracleTimeStamp structure.

Declaration

// C#
public static implicit operator OracleTimeStamp (OracleDate value1);

Parameters

  • value1

    An OracleDate instance.

Return Value

An OracleTimeStamp structure that contains the date and time of the OracleDate structure, value1.

Remarks

If the OracleDate structure has a null value, the returned OracleTimeStamp structure also has a null value.

implicit operator OracleTimeStamp(DateTime)

This static type conversion operator converts a DateTime value to an OracleTimeStamp structure.

Declaration

// C#
public static implicit operator OracleTimeStamp(DateTime value);

Parameters

  • value

    A DateTime instance.

Return Value

An OracleTimeStamp structure.

explicit operator DateTime

This static type conversion operator converts an OracleTimeStamp value to a DateTime structure.

Declaration

// C#
public static explicit operator DateTime(OracleTimeStamp value1);

Parameters

  • value1

    An OracleTimeStamp instance.

Return Value

A DateTime containing the date and time in the current instance.

Exceptions

OracleNullValueException - The OracleTimeStamp structure has a null value.

Remarks

The precision of the OracleTimeStamp can be lost during the conversion.


OracleTimeStamp Properties

The OracleTimeStamp properties are listed in Table 11-98.

Table 11-98 OracleTimeStamp Properties

Properties Description
BinData Returns an array of bytes that represents an Oracle TIMESTAMP in Oracle internal format
Day Specifies the day component of an OracleTimeStamp
IsNull Indicates whether or not the OracleTimeStamp instance has a null value
Hour Specifies the hour component of an OracleTimeStamp
Millisecond Specifies the millisecond component of an OracleTimeStamp
Minute Specifies the minute component of an OracleTimeStamp
Month Specifies the month component of an OracleTimeStamp
Nanosecond Specifies the nanosecond component of an OracleTimeStamp
Second Specifies the second component of an OracleTimeStamp
Value Specifies the date and time that is stored in the OracleTimeStamp structure
Year Specifies the year component of an OracleTimeStamp

BinData

This property returns an array of bytes that represents an Oracle TIMESTAMP in Oracle internal format.

Declaration

// C#
public byte[] BinData {get;}

Property Value

A byte array that represents an Oracle TIMESTAMP in an internal format.

Exceptions

OracleNullValueException - The current instance has a null value.

Day

This property specifies the day component of an OracleTimeStamp.

Declaration

// C#
public int Day{get;}

Property Value

A number that represents the day. Range of Day is (1 to 31).

Exceptions

OracleNullValueException - The current instance has a null value.

IsNull

This property indicates whether or not the current instance has a null value.

Declaration

// C#
public bool IsNull{get;}

Property Value

Returns true if the current instance has a null value; otherwise, returns false.

Hour

This property specifies the hour component of an OracleTimeStamp.

Declaration

// C#
public int Hour{get;}

Property Value

A number that represents the hour. Range of hour is (0 to 23).

Exceptions

OracleNullValueException - The current instance has a null value.

Millisecond

This property gets the millisecond component of an OracleTimeStamp.

Declaration

// C#
public double Millisecond{get;}

Property Value

A number that represents a millisecond. Range of Millisecond is (0 to 999.999999).

Exceptions

OracleNullValueException - The current instance has a null value.

Minute

This property gets the minute component of an OracleTimeStamp.

Declaration

// C#
public int Minute{get;}

Property Value

A number that represent a minute. Range of Minute is (0 to 59).

Exceptions

OracleNullValueException - The current instance has a null value.

Month

This property gets the month component of an OracleTimeStamp.

Declaration

// C#
public int Month{get;}

Property Value

A number that represents a month. Range of Month is (1 to 12).

Exceptions

OracleNullValueException - The current instance has a null value.

Nanosecond

This property gets the nanosecond component of an OracleTimeStamp.

Declaration

// C#
public int Nanosecond{get;}

Property Value

A number that represents a nanosecond. Range of Nanosecond is (0 to 999999999).

Exceptions

OracleNullValueException - The current instance has a null value.

Second

This property gets the second component of an OracleTimeStamp.

Declaration

// C#
public int Second{get;}

Property Value

A number that represents a second. Range of Second is (0 to 59).

Exceptions

OracleNullValueException - The current instance has a null value.

Value

This property specifies the date and time that is stored in the OracleTimeStamp structure.

Declaration

// C#
public DateTime Value{get;}

Property Value

A DateTime.

Exceptions

OracleNullValueException - The current instance has a null value.

Year

This property gets the year component of an OracleTimeStamp.

Declaration

// C#
public int Year{get;}

Property Value

A number that represents a year. The range of Year is (-4712 to 9999).

Exceptions

OracleNullValueException - The current instance has a null value.


OracleTimeStamp Methods

The OracleTimeStamp methods are listed in Table 11-99.

Table 11-99 OracleTimeStamp Methods

Methods Description
AddDays Adds the supplied number of days to the current instance
AddHours Adds the supplied number of hours to the current instance
AddMilliseconds Adds the supplied number of milliseconds to the current instance
AddMinutes Adds the supplied number of minutes to the current instance
AddMonths Adds the supplied number of months to the current instance
AddNanoseconds Adds the supplied number of nanoseconds to the current instance
AddSeconds Adds the supplied number of seconds to the current instance
AddYears Adds the supplied number of years to the current instance
CompareTo Compares the current OracleTimeStamp instance to an object, and returns an integer that represents their relative values
Equals Determines whether or not an object has the same date and time as the current OracleTimeStamp instance (Overloaded)
GetHashCode Returns a hash code for the OracleTimeStamp instance
GetDaysBetween Subtracts an OracleTimeStamp value from the current instance and returns an OracleIntervalDS that represents the time difference between the supplied OracleTimeStamp and the current instance
GetYearsBetween Subtracts value1 from the current instance and returns an OracleIntervalYM that represents the difference between value1 and the current instance using OracleIntervalYM
GetType Inherited from Object
ToOracleDate Converts the current OracleTimeStamp structure to an OracleDate structure
ToOracleTimeStampLTZ Converts the current OracleTimeStamp structure to an OracleTimeStampLTZ structure
ToOracleTimeStampTZ Converts the current OracleTimeStamp structure to an OracleTimeStampTZ structure
ToString Converts the current OracleTimeStamp structure to a string

AddDays

This method adds the supplied number of days to the current instance.

Declaration

// C#
public OracleTimeStamp AddDays(double days);

Parameters

  • days

    The supplied number of days. Range is (-1,000,000,000 < days < 1,000,000,000)

Return Value

An OracleTimeStamp.

Exceptions

ArgumentOutofRangeException - The argument value is out of the specified range.

OracleNullValueException - The current instance has a null value.

AddHours

This method adds the supplied number of hours to the current instance.

Declaration

// C#
public OracleTimeStamp AddHours(double hours);

Parameters

  • hours

    The supplied number of hours. Range is (-24,000,000,000 < hours < 24,000,000,000).

Return Value

An OracleTimeStamp.

Exceptions

ArgumentOutofRangeException - The argument value is out of the specified range.

OracleNullValueException - The current instance has a null value.

AddMilliseconds

This method adds the supplied number of milliseconds to the current instance.

Declaration

// C#
public OracleTimeStamp AddMilliseconds(double milliseconds);

Parameters

  • milliseconds

    The supplied number of milliseconds. Range is (-8.64 * 1016< milliseconds < 8.64 * 1016).

Return Value

An OracleTimeStamp.

Exceptions

ArgumentOutofRangeException - The argument value is out of the specified range.

OracleNullValueException - The current instance has a null value.

AddMinutes

This method adds the supplied number of minutes to the current instance.

Declaration

// C#
public OracleTimeStamp AddMinutes(double minutes);

Parameters

  • minutes

    The supplied number of minutes. Range is (-1,440,000,000,000 < minutes < 1,440,000,000,000).

Return Value

An OracleTimeStamp.

Exceptions

ArgumentOutofRangeException - The argument value is out of the specified range.

OracleNullValueException - The current instance has a null value.

AddMonths

This method adds the supplied number of months to the current instance.

Declaration

// C#
public OracleTimeStamp AddMonths(long months);

Parameters

  • months

    The supplied number of months. Range is (-12,000,000,000 < months < 12,000,000,000).

Return Value

An OracleTimeStamp.

Exceptions

ArgumentOutofRangeException - The argument value is out of the specified range.

OracleNullValueException - The current instance has a null value.

AddNanoseconds

This method adds the supplied number of nanoseconds to the current instance.

Declaration

// C#
public OracleTimeStamp AddNanoseconds(long nanoseconds);

Parameters

  • nanoseconds

    The supplied number of nanoseconds.

Return Value

An OracleTimeStamp.

Exceptions

OracleNullValueException - The current instance has a null value.

AddSeconds

This method adds the supplied number of seconds to the current instance.

Declaration

// C#
public OracleTimeStamp AddSeconds(double seconds);

Parameters

  • seconds

    The supplied number of seconds. Range is (-8.64 * 1013< seconds < 8.64 * 1013).

Return Value

An OracleTimeStamp.

Exceptions

ArgumentOutofRangeException - The argument value is out of the specified range.

OracleNullValueException - The current instance has a null value.

AddYears

This method adds the supplied number of years to the current instance.

Declaration

// C#
public OracleTimeStamp AddYears(int years);

Parameters

  • years

    The supplied number of years. Range is (-999,999,999 <= years < = 999,999,999)

Return Value

An OracleTimeStamp.

Exceptions

ArgumentOutofRangeException - The argument value is out of the specified range.

OracleNullValueException - The current instance has a null value.

CompareTo

This method compares the current OracleTimeStamp instance to an object, and returns an integer that represents their relative values.

Declaration

// C#
public int CompareTo(object obj);

Parameters

  • obj

    The object being compared to the current OracleTimeStamp instance.

Return Value

The method returns a number that is:

Less than zero: if the current OracleTimeStamp instance value is less than that of obj.

Zero: if the current OracleTimeStamp instance and obj values are equal.

Greater than zero: if the current OracleTimeStamp instance value is greater than that of obj.

Implements

IComparable

Exceptions

ArgumentException - The obj parameter is not of type OracleTimeStamp.

Remarks

The following rules apply to the behavior of this method.

  • The comparison must be between OracleTimeStamps. For example, comparing an OracleTimeStamp instance with an OracleBinary instance is not allowed. When an OracleTimeStamp is compared with a different type, an ArgumentException is thrown.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

Equals

Overrides Object

This method determines whether or not an object has the same date and time as the current OracleTimeStamp instance.

Declaration

// C#
public override bool Equals(object obj);

Parameters

  • obj

    The object being compared to the current OracleTimeStamp instance.

Return Value

Returns true if the obj is of type OracleTimeStamp and represents the same date and time; otherwise, returns false.

Remarks

The following rules apply to the behavior of this method.

  • Any OracleTimeStamp that has a value is greater than an OracleTimeStamp that has a null value.

  • Two OracleTimeStamps that contain a null value are equal.

GetHashCode

Overrides Object

This method returns a hash code for the OracleTimeStamp instance.

Declaration

// C#
public override int GetHashCode();

Return Value

A number that represents the hash code.

GetDaysBetween

This method subtracts an OracleTimeStamp value from the current instance and returns an OracleIntervalDS that represents the time difference between the supplied OracleTimeStamp structure and the current instance.

Declaration

// C#
public OracleIntervalDS GetDaysBetween(OracleTimeStamp value1);

Parameters

  • value1

    The OracleTimeStamp value being subtracted.

Return Value

An OracleIntervalDS that represents the interval between two OracleTimeStamp values.

Remarks

If either the current instance or the parameter has a null value, the returned OracleIntervalDS has a null value.

GetYearsBetween

This method subtracts an OracleTimeStamp value from the current instance and returns an OracleIntervalYM that represents the time difference between the OracleTimeStamp value and the current instance.

Declaration

// C#
public OracleIntervalYM GetYearsBetween(OracleTimeStamp value1);

Parameters

  • value1

    The OracleTimeStamp value being subtracted.

Return Value

An OracleIntervalYM that represents the interval between two OracleTimeStamp values.

Remarks

If either the current instance or the parameter has a null value, the returned OracleIntervalYM has a null value.

ToOracleDate

This method converts the current OracleTimeStamp structure to an OracleDate structure.

Declaration

// C#
public OracleDate ToOracleDate();

Return Value

The returned OracleDate contains the date and time in the current instance.

Remarks

The precision of the OracleTimeStamp value can be lost during the conversion.

If the value of the OracleTimeStamp has a null value, the value of the returned OracleDate structure has a null value.

ToOracleTimeStampLTZ

This method converts the current OracleTimeStamp structure to an OracleTimeStampLTZ structure.

Declaration

// C#
public OracleTimeStampLTZ ToOracleTimeStampLTZ();

Return Value

The returned OracleTimeStampLTZ contains date and time in the current instance.

Remarks

If the value of the current instance has a null value, the value of the returned OracleTimeStampLTZ structure has a null value.

ToOracleTimeStampTZ

This method converts the current OracleTimeStamp structure to an OracleTimeStampTZ structure.

Declaration

// C#
public OracleTimeStampTZ ToOracleTimeStampTZ();

Return Value

The returned OracleTimeStampTZ contains the date and time from the OracleTimeStamp and the time zone from the OracleGlobalization.TimeZone of the thread.

Remarks

If the value of the current instance has a null value, the value of the returned OracleTimeStampTZ structure has a null value.

ToString

Overrides Object

This method converts the current OracleTimeStamp structure to a string.

Declaration

// C#
public override string ToString();

Return Value

A string that represents the same date and time as the current OracleTimeStamp structure.

Remarks

The returned value is a string representation of an OracleTimeStamp in the format specified by the OracleGlobalization.TimeStampFormat property of the thread.

The names and abbreviations used for months and days are in the language specified by the OracleGlobalization's DateLanguage and Calendar properties of the thread. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.

Example

// C#
 
using System;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
 
class ToStringSample
{
  static void Main()
  {
    // Set the nls_timestamp_format for the OracleTimeStamp(string)
    // constructor
    OracleGlobalization info = OracleGlobalization.GetClientInfo();
    info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
    
    // construct OracleTimeStamp from a string using the format specified.
    OracleTimeStamp ts = new OracleTimeStamp("11-NOV-1999 11:02:33.444 AM");
    
    // Set the nls_timestamp_format for the ToString() method
    info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM";
    OracleGlobalization.SetThreadInfo(info);
 
    // Prints "1999-NOV-11 11:02:33.444000000 AM"      
    Console.WriteLine(ts.ToString());    
  }
}
PK3PKkUIOEBPS/featChange.htm\> Features of Oracle Data Provider for .NET

Database Change Notification Support

Oracle Data Provider for .NET provides a notification framework that supports Database Change Notification, enabling applications to receive notifications when there is a change in a query result set, schema objects, or the state of the database. Using Database Change Notification, an application can maintain the validity of the client-side cache (for example, the ADO.NET DataSet) easily.


Note:

Database Change Notification is not supported in a .NET stored procedure.

Using the notification framework, applications can specify a query result set as a registered query for notification request, and create this notification registration to maintain the validity of the query result set. When there is a change in the query result set, the notification framework notifies the application.


Note:

The content of a change notification is referred to as an invalidation message. It indicates that the query result set is now invalid and provides information about the changes.

Based on the information provided by the notification framework, the application can then act accordingly. For example, the application might need to refresh its own copy of the data for the registered query that is stored locally in the application.

The database notifies Oracle Data Provider for .NET of data changes made to the underlying tables when this data is being used on a .NET client.


Note:

If a registered object is dropped from the database and a new one is created with the same name in the same schema, re-registration is required to receive notifications for the newly created object.


See Also:

Oracle Database Application Developer's Guide - Fundamentals for further information on Database Change Notification

This section contains the following topics:

Database Change Notification Classes

The following classes are associated with the Database Change Notification Support:

  • OracleDependency

    Represents a dependency between an application and an Oracle database based on the database events which the application is interested in. It contains information about the dependency and provides the mechanism to notify the application when specified database events occurs. The OracleDependency class is also responsible for creating the notification listener to listen for database notifications. There is only one database notification listener for each application domain. This notification listener terminates when the application process terminates.

    The dependency between the application and the database is not established when the OracleDependency object is created. The dependency is established when the command that is associated with this OracleDependency object is executed. That command execution creates a database change notification registration in the database.

    When a change has occurred in the database, the HasChanges property of the OracleDependency object is set to true. Furthermore, if an event handler was registered with the OnChange event of the OracleDependency object, the registered event handler function will be invoked.

  • OracleNotificationRequest

    Represents a notification request to be registered in the database. It contains information about the request and the properties of the notification.

  • OracleNotificationEventArgs

    Represents the invalidation message generated for a notification when a specified database event occurs and contains details about that database event.

Supported Operations

The ODP.NET notification framework in conjunction with Database Change Notification supports the following activities:

  • Creating a notification registration by:

    • Creating an OracleDependency instance and binding it to an OracleCommand instance.

  • Grouping multiple notification requests into one registration by:

    • Using the OracleDependency.AddCommandDependency method.

    • Setting the OracleCommand.Notification request using the same OracleNotificationRequest instance.

  • Registering for database change notification by:

    • Executing the OracleCommand. If either the notification property is null or NotificationAutoEnlist is false, the notification will not be made.

  • Removing notification registration by:

    • Using the OracleDependency.RemoveRegistration method.

    • Setting the Timeout property in the OracleNotificationRequest instance before the registration is created.

    • Setting the IsNotifiedOnce property to true in the OracleNotificationRequest instance before the registration is created. The registration is removed once a database notification is sent.

  • Ensuring Change Notification Persistence by:

    • Specifying whether or not the invalidation message is queued persistently in the database before delivery. If an invalidation message is to be stored persistently in the database, then the change notification is guaranteed to be sent. If an invalidation message is stored in an in-memory queue, the change notification can be received faster, however, it could be lost upon database shutdown or crashes.

  • Retrieving notification information including:

    • The changed object name.

    • The schema name of the changed object.

    • Database events that cause the notification, such as insert, delete, and so on.

    • The RowID of the modified object row.

  • Defining the listener port number.

    By default, the static OracleDependency.Port property is set to -1. This indicates that the ODP.NET listens on a port that is randomly picked when ODP.NET registers a database change notification request for the first time during the execution of an application.

    ODP.NET creates only one listener that listens on one port within an application domain. Once ODP.NET starts the listener, the port number cannot be changed; Changes to the static OracleDependency.Port property are ignored.

    By default, all installations of Windows XP Service Pack 2 and higher enable the Windows Firewall to block virtually all TCP network ports to incoming connections. Therefore, for Database Change Notification to work properly on Windows XP Service Pack 2 and higher, the Windows Firewall must be configured properly to allow specific executables to open specific ports.

Requirements of Notification Registration

The connected user must have the CHANGE NOTIFICATION privilege to create a notification registration.

This SQL statement grants the CHANGE NOTIFICATION privilege:

grant change notification to user name

This SQL statement revokes the CHANGE NOTIFICATION privilege:

revoke change notification from user name

Using Database Change Notification

This section describes what the application should do, and the flow of the process, when an application uses Database Change Notification to receive notifications for any changes in the registered query result set.

Application Steps

The application should do the following:

  1. Create an OracleDependency instance.

  2. Assign an event handler to the OracleDependency.OnChange event property if the application wishes to have an event handler invoked when database changes are detected. Otherwise, the application can choose to poll on the HasChanges property of the OracleDependency object. This event handler is invoked when the change notification is received.

  3. Set the port number for the listener to listen on. The application can specify the port number for one notification listener to listen on. If the application does not specify a port number, a random one is used by the listener.

  4. Bind the OracleDependency instance to an OracleCommand instance that contains the actual query to be executed. Internally, the database change notification request (an OracleNotificationRequest instance) is created and assigned to the OracleCommand.Notification property.

Flow of Notification Process

  1. When the command associated with the notification request is executed, the notification registration is created in the database. The command execution must return a result set, or contain one or more REF cursors for a PL/SQL stored procedure.

  2. ODP.NET starts the application listener on the first successful notification registration.

  3. When a change related to the registration occurs in the database, the application is notified through the event delegate assigned to the OracleDependency.OnChange event property, or the application can poll the OracleDependency.HasChanges property.

The following example demonstrates the database change notification feature.

// Database Setup
// NOTE: unless the following SQL command is executed, 
// ORA-29972 will be obtained from running this sample
/*
grant change notification to scott;
*/
using System;
using System.Threading;
using System.Data;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
//This sample shows the database change notification feature in ODP.NET.
//Application specifies to get a notification when emp table is updated.
//When emp table is updated, the application will get a notification 
//through an event handler.
namespace NotificationSample 
{
  public class MyNotificationSample 
  {
    public static bool IsNotified = false;
 
    public static void Main(string[] args) 
    {
      //To Run this sample, make sure that the change notification privilege
      //is granted to scott.
      string constr = "User Id=scott;Password=tiger;Data Source=oracle";
      OracleConnection con = null;
      OracleDependency dep = null;
 
      try
      {
        con = new OracleConnection(constr);
        OracleCommand cmd = new OracleCommand("select * from emp", con);
        con.Open();
 
        // Set the port number for the listener to listen for the notification
        // request
        OracleDependency.Port = 1005; 
 
        // Create an OracleDependency instance and bind it to an OracleCommand
        // instance.
        // When an OracleDependency instance is bound to an OracleCommand
        // instance, an OracleNotificationRequest is created and is set in the
        // OracleCommand's Notification property. This indicates subsequent 
        // execution of command will register the notification.
        // By default, the notification request is using the Database Change
        // Notification.
        dep = new OracleDependency(cmd);
 
        // Add the event handler to handle the notification. The 
        // OnMyNotification method will be invoked when a notification message
        // is received from the database
        dep.OnChange += 
          new OnChangeEventHandler(MyNotificationSample.OnMyNotificaton);
 
        // The notification registration is created and the query result sets 
        // associated with the command can be invalidated when there is a 
        // change.  When the first notification registration occurs, the 
        // notification listener is started and the listener port number 
        // will be 1005.
        cmd.ExecuteNonQuery();
 
        // Updating emp table so that a notification can be received when
        // the emp table is updated.
        // Start a transaction to update emp table
        OracleTransaction txn = con.BeginTransaction();
        // Create a new command which will update emp table
        string updateCmdText = 
          "update emp set sal = sal + 10 where empno = 7782";
        OracleCommand updateCmd = new OracleCommand(updateCmdText, con);
        // Update the emp table
        updateCmd.ExecuteNonQuery();
        //When the transaction is committed, a notification will be sent from
        //the database
        txn.Commit();
      }
      catch (Exception e)
      {
        Console.WriteLine(e.Message);
      }
 
      con.Close();
      // Loop while waiting for notification
      while(MyNotificationSample.IsNotified == false)
      {
        Thread.Sleep(100);
      }
    }
 
    public static void OnMyNotificaton(object src, 
      OnChangeEventArgs arg) 
    {
      Console.WriteLine("Notification Received");
      DataTable changeDetails = arg.Details;
      Console.WriteLine("Data has changed in {0}", 
        changeDetails.Rows[0]["ResourceName"]);
      MyNotificationSample.IsNotified = true;
    }
  }
}

Best Practice Guidelines and Performance Considerations

This section provides guidelines for working with Database Change Notification and the ODP.NET notification framework, and discusses the performance impacts.Every change notification registration consumes database memory, storage or network resources, or some combination thereof. The resource consumption further depends on the volume and size of the invalidation message. In order to scale well with a large number of mid-tier clients, Oracle recommends that the client implement these best practices:

  • Few and mostly read-only tables

    There should be few registered objects, and these should be mostly read-only, with very infrequent invalidations. If an object is extremely volatile, then a large number of invalidation notifications are sent, potentially requiring a lot of space (in memory or on disk) in the invalidation queue. This is also true if a large number of objects are registered.

  • Few rows updated for each table

    Transactions should update (or insert or delete) only a small number of rows within the registered tables. Depending on database resources, a whole table could be invalidated if too many rows are updated within a single transaction, for a given table.

    This policy helps to contain the size of a single invalidation message, and reduces disk storage for the invalidation queue.


See Also:

Oracle Database Application Developer's Guide - Fundamentalsfor further information on Database Change Notification

PKl\\PKkUIOEBPS/typeobjs.htmB Oracle Data Provider for .NET Types Classes

10 Oracle Data Provider for .NET Types Classes

This chapter describes the large object and REF CURSOR objects provided by Oracle Data Provider for .NET.

This chapter contains these topics:

All offsets are 0-based for all ODP.NET LOB object parameters.

PKGBPKkUIOEBPS/OracleExceptionClass.htm{ Oracle Data Provider for .NET Classes

OracleException Class

The OracleException class represents an exception that is thrown when the Oracle Data Provider for .NET encounters an error. Each OracleException object contains at least one OracleError object in the Error property that describes the error or warning.

Class Inheritance

Object

  Exception

    SystemException

      OracleException

Declaration

// C#
public sealed class OracleException : SystemException

Thread Safety

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

Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client;
 
class OracleExceptionSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    // Create an OracleCommand object using the connection object
    OracleCommand cmd = con.CreateCommand();
 
    try
    {
      cmd.CommandText = "insert into notable values (99, 'MyText')";
      cmd.ExecuteNonQuery();
    }
    catch (OracleException ex)
    {
      Console.WriteLine("Record is not inserted into the database table.");
      Console.WriteLine("Exception Message: " + ex.Message);
      Console.WriteLine("Exception Source: " + ex.Source);
    }
  }
}

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll


OracleException Members

OracleException members are listed in the following tables:

OracleException Static Methods

The OracleException static method is listed in Table 5-57.

Table 5-57 OracleException Static Method

Method Description
Equals Inherited from Object (Overloaded)

OracleException Properties

OracleException properties are listed in Table 5-58.

Table 5-58 OracleException Properties

Properties Description
DataSource Specifies the TNS name that contains the information for connecting to an Oracle instance
Errors Specifies a collection of one or more OracleError objects that contain information about exceptions generated by the Oracle database
HelpLink Inherited from Exception
InnerException Inherited from Exception
Message Specifies the error messages that occur in the exception
Number Specifies the Oracle error number
Procedure Specifies the stored procedure that cause the exception
Source Specifies the name of the data provider that generates the error
StackTrace Inherited from Exception
TargetSite Inherited from Exception

OracleException Methods

OracleException methods are listed in Table 5-59.

Table 5-59 OracleException Methods

Methods Description
Equals Inherited from Object (Overloaded)
GetBaseException Inherited from Exception
GetHashCode Inherited from Object
GetObjectData Sets the serializable info object with information about the exception
GetType Inherited from Object
ToString Returns the fully qualified name of this exception


OracleException Static Methods

The OracleException static method is listed in Table 5-60.

Table 5-60 OracleException Static Method

Method Description
Equals Inherited from Object (Overloaded)


OracleException Properties

OracleException properties are listed in Table 5-61.

Table 5-61 OracleException Properties

Properties Description
DataSource Specifies the TNS name that contains the information for connecting to an Oracle instance
Errors Specifies a collection of one or more OracleError objects that contain information about exceptions generated by the Oracle database
HelpLink Inherited from Exception
InnerException Inherited from Exception
Message Specifies the error messages that occur in the exception
Number Specifies the Oracle error number
Procedure Specifies the stored procedure that cause the exception
Source Specifies the name of the data provider that generates the error
StackTrace Inherited from Exception
TargetSite Inherited from Exception

DataSource

This property specifies the TNS name that contains the information for connecting to an Oracle instance.

Declaration

// C#
public string DataSource {get;}

Property Value

The TNS name containing the connect information.

Errors

This property specifies a collection of one or more OracleError objects that contain information about exceptions generated by the Oracle database.

Declaration

// C#
public OracleErrorCollection Errors {get;}

Property Value

An OracleErrorCollection.

Remarks

The Errors property contains at least one instance of OracleError objects.

Message

Overrides Exception

This property specifies the error messages that occur in the exception.

Declaration

// C#
public override string Message {get;}

Property Value

A string.

Remarks

Message is a concatenation of all errors in the Errors collection. Each error message is concatenated and is followed by a carriage return, except the last one.

Number

This property specifies the Oracle error number.

Declaration

// C#
public int Number {get;}

Property Value

The error number.

Remarks

This error number can be the topmost level of error generated by Oracle and can be a provider-specific error number.

Procedure

This property specifies the stored procedure that caused the exception.

Declaration

// C#
public string Procedure {get;}

Property Value

The stored procedure name.

Source

Overrides Exception

This property specifies the name of the data provider that generates the error.

Declaration

// C#
public override string Source {get;}

Property Value

The name of the data provider.


OracleException Methods

OracleException methods are listed in Table 5-62.

Table 5-62 OracleException Methods

Methods Description
Equals Inherited from Object (Overloaded)
GetBaseException Inherited from Exception
GetHashCode Inherited from Object
GetObjectData Sets the serializable info object with information about the exception
GetType Inherited from Object
ToString Returns the fully qualified name of this exception

GetObjectData

Overrides Exception

This method sets the serializable info object with information about the exception.

Declaration

// C#
public override void GetObjectData(SerializationInfo info, StreamingContext 
    context);

Parameters

  • info

    A SerializationInfo object.

  • context

    A StreamingContext object.

Remarks

The information includes DataSource, Message, Number, Procedure, Source, and StackTrace.

ToString

Overrides Exception

This method returns the fully qualified name of this exception, the error message in the Message property, the InnerException.ToString() message, and the stack trace.

Declaration

// C#
public override string ToString();

Return Value

The string representation of the exception.

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
 
class ToStringSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    // Create an OracleCommand object using the connection object
    OracleCommand cmd = con.CreateCommand();
 
    try
    {
      cmd.CommandText = "insert into notable values (99, 'MyText')";
      cmd.ExecuteNonQuery();  // This will throw an exception
    }
    catch (OracleException ex)
    {
      Console.WriteLine("Record is not inserted into the database table.");
      Console.WriteLine("ex.ToString() : " + ex.ToString());
    }
  }
}
PK>m{{PKkUIOEBPS/intro002.htm Introducing Oracle Data Provider for .NET

Overview of Oracle Data Provider for .NET (ODP.NET)

Oracle Data Provider for .NET (ODP.NET) is an implementation of a .NET data provider for Oracle Database, using and inheriting from classes and interfaces available in the Microsoft .NET Framework Class Library.

Following the .NET Framework, ODP.NET uses the ADO.NET model, which allows native providers to expose provider-specific features and datatypes. This is similar to Oracle Provider for OLE DB, where ADO (ActiveX Data Objects) provides an automation layer that exposes an easy programming model. ADO.NET provides a similar programming model, but without the automation layer, for better performance.

Oracle Data Provider for .NET uses Oracle native APIs to offer fast and reliable access to Oracle data and features from any .NET application.

The ODP.NET classes described in this guide are contained in the Oracle.DataAccess.dll assembly.

  • Client Applications: All ODP.NET classes are available for use in client applications.

  • .NET Stored Procedures: Most ODP.NET classes can be used from within .NET stored procedures and functions. Those classes which cannot, are labeled Not Supported in a .NET Stored Procedure. Additionally, some classes contain members which may not be supported, and this is so indicated in the member tables that follow the class descriptions, and listed in Chapter 4 of this guide.

PK8ӞPKkUIOEBPS/OracleBlobClass.htm Oracle Data Provider for .NET Types Classes

OracleBlob Class

An OracleBlob object is an object that has a reference to BLOB data. It provides methods for performing operations on BLOBs.

Class Inheritance

Object

  MarshalByRefObject

    Stream

      OracleBlob

Declaration

// C#
public sealed class OracleBlob : Stream, ICloneable

Thread Safety

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

Example

// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class OracleBlobSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    OracleBlob blob = new OracleBlob(con);
      
    // Write 4 bytes from writeBuffer, starting at buffer offset 0
    byte[] writeBuffer = new byte[4] {1, 2, 3, 4};
    blob.Write(writeBuffer, 0, 4);    
 
    // Append first 2 bytes from writeBuffer {1, 2} to the oracleBlob
    blob.Append(writeBuffer, 0, 2);
 
    // Prints "blob.Length  = 6"
    Console.WriteLine("blob.Length  = " + blob.Length);
 
    // Reset the Position for the Read
    blob.Position = 0;
 
    // Read 6 bytes into readBuffer, starting at buffer offset 0
    byte[] readBuffer = new byte[6];       
    int bytesRead = blob.Read(readBuffer, 0, 6);
    
    // Prints "bytesRead    = 6"
    Console.WriteLine("bytesRead    = " + bytesRead);    
 
    // Prints "readBuffer   = 123412"
    Console.Write("readBuffer   = ");
    for(int index = 0; index <  readBuffer.Length; index++)
    {
      Console.Write(readBuffer[index]);
    }
    Console.WriteLine();
        
    // Search for the 2nd occurrence of a byte pattern '12'
    // starting from byte offset 0 in the OracleBlob
    byte[] pattern = new byte[2] {1, 2};
    long posFound = blob.Search(pattern, 0, 2);
 
    // Prints "posFound     = 5" 
    Console.WriteLine("posFound     = " + posFound);
 
    // Erase 4 bytes of data starting at byte offset 1
    // Sets bytes to zero
    blob.Erase(1, 4);
 
    byte[] erasedBuffer = blob.Value;    
 
    //Prints "erasedBuffer = 100002"
    Console.Write("erasedBuffer = ");
    for(int index = 0; index < erasedBuffer.Length; index++)
    {
      Console.Write(erasedBuffer[index]);
    }
    Console.WriteLine();
 
    blob.Close();
    blob.Dispose();
 
    con.Close();
    con.Dispose();
  }
}

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll


OracleBlob Members

OracleBlob members are listed in the following tables:

OracleBlob Constructors

OracleBlob constructors are listed in Table 10-10.

Table 10-10 OracleBlob Constructors

Constructor Description
OracleBlob Constructors
Creates an instance of the OracleBlob class (Overloaded)

OracleBlob Static Fields

OracleBlob static fields are listed in Table 10-11.

Table 10-11 OracleBlob Static Fields

Field Description
MaxSize
Holds the maximum number of bytes a BLOB can hold, which is 4,294,967,295 (2^32 - 1) bytes

OracleBlob Static Methods

OracleBlob static methods are listed in Table 10-12.

Table 10-12 OracleBlob Static Methods

Methods Description
Equals Inherited from Object (Overloaded)

OracleBlob Instance Properties

OracleBlob instance properties are listed in Table 10-13.

Table 10-13 OracleBlob Instance Properties

Properties Description
CanRead
Indicates whether or not the LOB stream can be read
CanSeek
Indicates whether or not forward and backward seek operations be performed
CanWrite
Indicates whether or not the LOB object supports writing
Connection
Indicates the OracleConnection that is used to retrieve and write BLOB data
IsEmpty
Indicates whether the BLOB is empty or not
IsInChunkWriteMode
Indicates whether or not the BLOB has been opened to defer index updates
IsTemporary
Indicates whether or not the current instance is bound to a temporary BLOB
Length
Indicates the size of the BLOB data
OptimumChunkSize
Indicates the optimal data buffer length (or multiples thereof) that read and write operations should use to improve performance
Position
Indicates the current read or write position in the LOB stream
Value
Returns the data, starting from the first byte in BLOB, as a byte array

OracleBlob Instance Methods

OracleBlob instance methods are listed in Table 10-14.

Table 10-14 OracleBlob Instance Methods

Methods Description
Append
Appends the supplied data to the current OracleBlob instance (Overloaded)
BeginChunkWrite
Opens the BLOB
BeginRead Inherited from Stream
BeginWrite Inherited from Stream
Clone
Creates a copy of an OracleBlob object
Close
Closes the current stream and releases any resources associated with it
Compare
Compares data referenced by the current instance and that of the supplied object
CopyTo
Copies from the current OracleBlob instance to an OracleBlob object (Overloaded)
CreateObjRef Inherited from MarshalByRefObject
Dispose
Releases resources allocated by this object
EndChunkWrite
Closes the BLOB referenced by the current OracleBlob instance
EndRead Inherited from Stream
EndWrite Inherited from Stream
Equals Inherited from Object (Overloaded)
Erase
Erases data (Overloaded)
Flush Not supported
GetHashCode Inherited from Object
GetLifetimeService Inherited from MarshalByRefObject
GetType Inherited from Object
InitializedLifetimeService Inherited from MarshalByRefObject
IsEqual
Compares the LOB data referenced by the two OracleBlobs
Read
Reads a specified amount of bytes from the ODP.NET LOB Type instance and populates the buffer
ReadByte Inherited from Stream
Search
Searches for a binary pattern in the current instance of an OracleBlob
Seek
Sets the position in the current LOB stream
SetLength
Trims or truncates the BLOB value to the specified length
ToString Inherited from Object
Write
Writes the supplied buffer into the OracleBlob
WriteByte Inherited from Stream


OracleBlob Constructors

OracleBlob constructors are listed in Table 10-10.

Overload List:

  • OracleBlob(OracleConnection)

    This constructor creates an instance of the OracleBlob class bound to a temporary BLOB with an OracleConnection object.

  • OracleBlob(OracleConnection, bool)

    This constructor creates an instance of the OracleBlob class bound to a temporary BLOB with an OracleConnection object and a boolean value for caching.

OracleBlob(OracleConnection)

This constructor creates an instance of the OracleBlob class bound to a temporary BLOB with an OracleConnection object.

Declaration

// C#
public OracleBlob(OracleConnection con);

Parameters

  • con

    The OracleConnection object.

Exceptions

InvalidOperationException - The OracleConnection is not opened.

Remarks

The connection must be opened explicitly by the application. OracleBlob does not open the connection implicitly.

The temporary BLOB utilizes the provided connection to store BLOB data. Caching is not turned on by this constructor.

OracleBlob(OracleConnection, bool)

This constructor creates an instance of the OracleBlob class bound to a temporary BLOB with an OracleConnection object and a boolean value for caching.

Declaration

// C#
public OracleBlob(OracleConnection con, bool bCaching);

Parameters

  • con

    The OracleConnection object.

  • bCaching

    A flag for enabling or disabling server-side caching.

Exceptions

InvalidOperationException - The OracleConnection is not opened.

Remarks

The connection must be opened explicitly by the application. OracleBlob does not open the connection implicitly.

The temporary BLOB uses the provided connection to store BLOB data. The bCaching input parameter determines whether or not server-side caching is used.


OracleBlob Static Fields

OracleBlob static fields are listed in Table 10-15.

Table 10-15 OracleBlob Static Fields

Field Description
MaxSize
Holds the maximum number of bytes a BLOB can hold, which is 4,294,967,295 (2^32 - 1) bytes

MaxSize

The MaxSize field holds the maximum number of bytes a BLOB can hold, which is 4,294,967,295 (2^32 - 1) bytes.

Declaration

// C#
public static readonly Int64 MaxSize = 4294967295;

Remarks

This field can be useful in code that checks whether or not the operation exceeds the maximum length allowed.


OracleBlob Static Methods

OracleBlob static methods are listed in Table 10-16.

Table 10-16 OracleBlob Static Methods

Methods Description
Equals Inherited from Object (Overloaded)


OracleBlob Instance Properties

OracleBlob instance properties are listed in Table 10-17.

Table 10-17 OracleBlob Instance Properties

Properties Description
CanRead
Indicates whether or not the LOB stream can be read
CanSeek
Indicates whether or not forward and backward seek operations be performed
CanWrite
Indicates whether or not the LOB object supports writing
Connection
Indicates the OracleConnection that is used to retrieve and write BLOB data
IsEmpty
Indicates whether the BLOB is empty or not
IsInChunkWriteMode
Indicates whether or not the BLOB has been opened to defer index updates
IsTemporary
Indicates whether or not the current instance is bound to a temporary BLOB
Length
Indicates the size of the BLOB data
OptimumChunkSize
Indicates the optimal data buffer length (or multiples thereof) that read and write operations should use to improve performance
Position
Indicates the current read or write position in the LOB stream
Value
Returns the data, starting from the first byte in BLOB, as a byte array

CanRead

Overrides Stream

This instance property indicates whether or not the LOB stream can be read.

Declaration

// C#
public override bool CanRead{get;}

Property Value

If the LOB stream can be read, returns true; otherwise, returns false.

CanSeek

Overrides Stream

This instance property indicates whether or not forward and backward seek operations can be performed.

Declaration

// C#
public override bool CanSeek{get;}

Property Value

If forward and backward seek operations can be performed, returns true; otherwise, returns false.

CanWrite

Overrides Stream

This instance property indicates whether or not the LOB object supports writing.

Declaration

// C#
public override bool CanWrite{get;}

Property Value

If the LOB stream can be written, returns true; otherwise, returns false.

Connection

This instance property indicates the OracleConnection that is used to retrieve and write BLOB data.

Declaration

// C#
public OracleConnection Connection {get;}

Property Value

An object of OracleConnection.

Exceptions

ObjectDisposedException - The object is already disposed.

IsEmpty

This instance property indicates whether the BLOB is empty or not.

Declaration

// C#
public bool IsEmpty {get;}

Property Value

A bool that indicates whether or not the BLOB is empty.

Exceptions

ObjectDisposedException - The object is already disposed.

IsInChunkWriteMode

This instance property indicates whether or not the BLOB has been opened to defer index updates.

Declaration

// C#
public bool IsInChunkWriteMode{get;}

Property Value

If the BLOB has been opened, returns true; otherwise, returns false.

IsTemporary

This instance property indicates whether or not the current instance is bound to a temporary BLOB.

Declaration

// C#
public bool IsTemporary {get;}

Property Value

bool

Length

Overrides Stream

This instance property indicates the size of the BLOB data in bytes.

Declaration

// C#
public override Int64 Length {get;}

Property Value

A number indicating the size of the BLOB data in bytes.

Exceptions

ObjectDisposedException - The object is already disposed.

InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.

OptimumChunkSize

This instance property indicates the optimal data buffer length (or multiples thereof) that read and write operations should use to improve performance.

Declaration

// C#
public int OptimumChunkSize{get;}

Property Value

A number representing the minimum bytes to retrieve or send.

Exceptions

ObjectDisposedException - The object is already disposed.

Position

Overrides Stream

This instance property indicates the current read or write position in the LOB stream.

Declaration

// C#
public override Int64 Position{get; set;}

Property Value

An Int64 that indicates the read or write position.

Exceptions

ObjectDisposedException - The object is already disposed.

InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.

ArgumentOutOfRangeException - The Position is less than 0.

Value

This instance property returns the data, starting from the first byte in the BLOB, as a byte array.

Declaration

// C#
public Byte[] Value{get;}

Property Value

A byte array.

Exceptions

ObjectDisposedException - The object is already disposed.

InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.

ArgumentOutOfRangeException - The Value is less than 0.

Remarks

The value of Position is not used or changed by using this property. 2 GB is the maximum byte array length that can be returned by this property.


OracleBlob Instance Methods

OracleBlob instance methods are listed in Table 10-18.

Table 10-18 OracleBlob Instance Methods

Methods Description
Append
Appends the supplied data to the current OracleBlob instance (Overloaded)
BeginChunkWrite
Opens the BLOB
BeginRead Inherited from Stream
BeginWrite Inherited from Stream
Clone
Creates a copy of an OracleBlob object
Close
Closes the current stream and releases any resources associated with it