Skip Headers

Oracle Data Provider for .NET Developer's Guide
Release 9.2.0.2

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

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

Oracle.DataAccess.Client Namespace, 15 of 26


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#
...
OracleParameter [] prm = new OracleParameter[3];

// Create OracleParameter objects through OracleParameterCollection
prm[0] = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, 1234, 
    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.CommandType = CommandType.CommandText;
cmd.ExecuteNonQuery();
...

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccesss.dll

See Also:

OracleParameter Members

OracleParameter members are listed in the following tables:

OracleParameter Constructors

OracleParameter constructors are listed in Table 4-87.

Table 4-87 OracleParameter Constructors
Constructor Description

OracleParameter Constructors

Instantiates a new instance of OracleParameter class (Overloaded)

OracleParameter Static Methods

OracleParameter static methods are listed in Table 4-88.

Table 4-88 OracleParameter Static Methods  
Methods Description

Equals

Inherited from Object (Overloaded)

OracleParameter Properties

OracleParameter properties are listed in Table 4-89.

Table 4-89 OracleParameter Properties  
Name Description

ArrayBindSize

Specifies the input or output size of a parameter before or after an Array Bind execution

ArrayBindStatus

Specifies the input or output status of a parameter before or after an Array Bind execution

DbType

Specifies the datatype of the parameter using the SystemDataDbType 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

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 server

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 4-90.

Table 4-90 OracleParameter Public Methods  
Public Method Description

Clone

Creates a 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)

See Also:

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
Remarks

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

Default Values:

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
Remarks

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

Default Values:

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
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:

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
Remarks

Changing the DbType implicitly changes the OracleDbType.

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

Default Values:

OracleParameter Static Methods

OracleParameter static methods are listed in Table 4-91.

Table 4-91 OracleParameter Static Methods  
Methods Description

Equals

Inherited from Object (Overloaded)

See Also:

OracleParameter Properties

OracleParameter properties are listed in Table 4-92.

Table 4-92 OracleParameter Properties  
Name Description

ArrayBindSize

Specifies the input or output size of a parameter before or after an Array Bind execution

ArrayBindStatus

Specifies the input or output status of a parameter before or after an Array Bind execution

DbType

Specifies the datatype of the parameter using the SystemDataDbType 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

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 server

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

See Also:

ArrayBindSize

This property specifies the input or output size of a parameter before or after an Array Bind execution.

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

An array of int values specifying the size.

Remarks

Used for Array Bind execution only.

Example
// C#
...
OracleParameter Param = new OracleParameter("name", OracleDbType.Varchar2);
Param.ArrayBindSize = new Int32[3];

// These sizes indicate the maximum size of the parameter value.
Param.ArrayBindSize[0] = 100;
Param.ArrayBindSize[1] = 300;
Param.ArrayBindSize[2] = 200;
...

See Also:

ArrayBindStatus

This property specifies the input or output status of a parameter before or after an Array Bind execution.

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

An array of OracleParameterStatus enumerated values.

Remarks

Used for Array Bind operation only.

See Also:

DbType

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

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

DbType

Implements

IDataParameter

Exceptions

ArgumentException - The DbType value specified is invalid.

Remarks

Default = DbType.String

Due to the link between the DbType and the OracleDbType properties, if the DbType property is set, the OracleDbType property becomes a supporting OracleDbType.

See Also:

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

ParameterDirection

Implements

IDataParameter

Exceptions

ArgumentOutOfRangeException - The ParameterDirection value specified is invalid.

Remarks

Default = ParameterDirection.Input

See Also:

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

The Offset property is used for binary and string types. 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 which have these types:

OracleDbType

This property specifies the Oracle datatype.

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

An OracleDbType enumerated value.

Remarks

Default = OracleDbType.Varchar2

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

See Also:

ParameterName

This property specifies the name of the parameter.

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

String

Implements

IDataParameter

Remarks

Default = null

The max size of ParameterName is 30 characters.

See Also:

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 which have OracleDbType.Decimal.

Oracle supports Precision of range 0 to 38.

See Also:

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 which have an OracleDbType.Decimal.

Oracle supports Scale between -84 and 128.

See Also:

Size

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

Declaration
// C#
public int Size { get; set;}
Property Value

int

Exceptions

ArgumentOutOfRangeException - The Size value specified is invalid.

Remarks

The default value is 0.

Size is used for parameters which have variable lengths as follows:

The value of Size is handled as follows:

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.


See Also:

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

See Also:

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().

See Also:

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

Status indicates whether:

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.

Remarks

Default = null

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.

See Also:

For input parameters the value is:

For output parameters the value is:

When array binding is used with:

If array binding is used, the value of ArrayBindCount should be the same for each parameter in a command.

If the values of ArrayBindCount are not the same in the parameters collection, the minimum value of ArrayBindCount in the parameters collection is used so that the array binding feature can be performed correctly.

Each parameter should have a value, even for array binding. To bind a parameter with a null value, set Value to DBNull.Value, or set Status to OracleParameterStatus. NullValue.

See Also:

OracleParameter Public Methods

OracleParameter public methods are listed in Table 4-93.

Table 4-93 OracleParameter Public Methods  
Public Method Description

Clone

Creates a 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)

See Also:

Clone

This method creates a 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#
...
//Need a proper casting for the return value when cloned
OracleParameter param_cloned = (OracleParameter) param.Clone();
...

See Also:

Dispose

This method releases resources allocated for an OracleParameter object.

Declaration
// C#
public void Dispose();
Implements

IDisposable

See Also:


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

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