| Oracle Data Provider for .NET Developer's Guide Release 9.2.0.2 Part Number A96160-01 |
|
Oracle.DataAccess.Client Namespace, 15 of 26
An OracleParameter object represents a parameter for an OracleCommand or a DataSet column.
Object
MarshalByRefObject
OracleParameter
// C# public sealed class OracleParameter : MarshalByRefObject, IDBDataParameter, IDataParameter, IDisposable, ICloneable
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
ArgumentException - The type binding is invalid.
// 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(); ...
Namespace: Oracle.DataAccess.Client
Assembly: Oracle.DataAccesss.dll
OracleParameter members are listed in the following tables:
OracleParameter constructors are listed in Table 4-87.
| Constructor | Description |
|---|---|
|
Instantiates a new instance of |
OracleParameter static methods are listed in Table 4-88.
| Methods | Description |
|---|---|
|
|
Inherited from |
OracleParameter properties are listed in Table 4-89.
OracleParameter public methods are listed in Table 4-90.
OracleParameter constructors instantiate new instances of the OracleParameter class.
This constructor instantiates a new instance of OracleParameter class.
This constructor instantiates a new instance of OracleParameter class using the supplied parameter name and Oracle datatype.
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name and parameter value.
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, and parameter direction.
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, value, and direction.
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, and size.
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, size, and source column.
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.
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, size, value, and direction.
This constructor instantiates a new instance of OracleParameter class.
// C# public OracleParameter();
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
This constructor instantiates a new instance of OracleParameter class using the supplied parameter name and Oracle datatype.
// C# public OracleParameter(string parameterName, OracleDbType oraType);
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
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name and parameter value.
// C# public OracleParameter(string parameterName, object obj);
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
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, and parameter direction.
// C# public OracleParameter(string parameterName, OracleDbType type, ParameterDirection direction);
parameterName
Specifies the parameter name.
type
Specifies the datatype of the OracleParameter.
direction
Specifies the direction of the OracleParameter.
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
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, value, and direction.
// C# public OracleParameter(string parameterName, OracleDbType type, object obj, ParameterDirection direction);
parameterName
Specifies the parameter name.
type
Specifies the datatype of the OracleParameter.
obj
Specifies the value of the OracleParameter.
direction
Specifies one of the ParameterDirection values.
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
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, and size.
// C# public OracleParameter(string parameterName, OracleDbType type, int size);
parameterName
Specifies the parameter name.
type
Specifies the datatype of the OracleParameter.
size
Specifies the size of the OracleParameter value.
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
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, size, and source column.
// C# public OracleParameter(string parameterName, OracleDbType type, int size, string srcColumn);
parameterName
Specifies the parameter name.
type
Specifies the datatype of the OracleParameter.
size
Specifies the size of the OracleParameter value.
srcColumn
Specifies the name of the source column.
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
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.
// C#
public OracleParameter(string parameterName, OracleDbType oraType, int size,
ParameterDirection direction, bool isNullable, byte precision, byte scale,
string srcColumn, DataRowVersion srcVersion, object obj);
parameterName
Specifies the parameter name.
oraType
Specifies the datatype of the OracleParameter.
size
Specifies the size of the OracleParameter value.
direction
Specifies ParameterDirection value.
isNullable
Specifies if the parameter value can be null.
precision
Specifies the precision of the parameter value.
scale
Specifies the scale of the parameter value.
srcColumn
Specifies the name of the source column.
srcVersion
Specifies one of the DataRowVersion values.
obj
Specifies the parameter value.
ArgumentException - The supplied value does not belong to the type of Value property in any of the OracleTypes.
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
This constructor instantiates a new instance of the OracleParameter class using the supplied parameter name, datatype, size, value, and direction.
// C# public OracleParameter(string parameterName, OracleDbType type, int size, object obj, ParameterDirection direction);
parameterName
Specifies the parameter name.
type
Specifies the datatype of the OracleParameter.
size
Specifies the size of the OracleParameter value.
obj
Specifies the value of the OracleParameter.
direction
Specifies one of the ParameterDirection values.
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 are listed in Table 4-91.
| Methods | Description |
|---|---|
|
|
Inherited from |
OracleParameter properties are listed in Table 4-92.
This property specifies the input or output size of a parameter before or after an Array Bind execution.
// C# public int[] ArrayBindSize {get; set; }
An array of int values specifying the size.
Used for Array Bind execution only.
// 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; ...
This property specifies the input or output status of a parameter before or after an Array Bind execution.
// C# public OracleParameterStatus[] ArrayBindStatus { get; set; }
An array of OracleParameterStatus enumerated values.
Used for Array Bind operation only.
This property specifies the datatype of the parameter using the Data.DbType enumeration type.
// C# public DbType DbType {get; set; }
DbType
IDataParameter
ArgumentException - The DbType value specified is invalid.
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.
This property specifies whether the parameter is input-only, output-only, bi-directional, or a stored function return value parameter.
// C# public ParameterDirection Direction { get; set; }
ParameterDirection
IDataParameter
ArgumentOutOfRangeException - The ParameterDirection value specified is invalid.
Default = ParameterDirection.Input
This property specifies the offset to the Value property.
// C# public int Offset { get; set; }
An int that specifies the offset.
ArgumentOutOfRangeException - The Offset value specified is invalid.
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.Bfile
OracleDbType.Blob
OracleDbType.LongRaw
OracleDbType.Raw
OracleDbType.Char
OracleDbType.Clob
OracleDbType.NClob
OracleDbType.NChar
OracleDbType.NVarchar2
OracleDbType.Varchar2
This property specifies the Oracle datatype.
// C# public OracleDbType OracleDbType { get; set; }
An OracleDbType enumerated value.
Default = OracleDbType.Varchar2
The OracleDbType property and DbType property are linked. Therefore, setting the OracleDbType property changes the DbType property to a supporting DbType.
This property specifies the name of the parameter.
// C# public string ParameterName { get; set; }
String
IDataParameter
Default = null
The max size of ParameterName is 30 characters.
This property specifies the maximum number of digits used to represent the Value property.
// C# Public byte Precision { get; set; }
byte
Default = 0
The Precision property is used by parameters which have OracleDbType.Decimal.
Oracle supports Precision of range 0 to 38.
This property specifies the number of decimal places to which Value property is resolved.
// C# public byte Scale { get; set; }
byte
Default = 0
Scale is used by parameters which have an OracleDbType.Decimal.
Oracle supports Scale between -84 and 128.
This property specifies the maximum size, in bytes or characters, of the data transmitted to or from the server.
// C# public int Size { get; set;}
int
ArgumentOutOfRangeException - The Size value specified is invalid.
The default value is 0.
Size is used for parameters which have variable lengths as follows:
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:
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.
This property specifies the name of the DataTable Column of the DataSet.
// C# public string SourceColumn { get; set; }
A string.
IDataParameter
Default = empty string
This property specifies the DataRowVersion value to use when loading the Value property of the parameter.
// C# public DataRowVersion SourceVersion { get; set; }
DataRowVersion
IDataParameter
ArgumentOutOfRangeException - The DataRowVersion value specified is invalid.
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().
This property indicates the status of the execution related to the data in the Value property.
// C# public OracleParameterStatus Status { get; set; }
An OracleParameterStatus enumerated value.
ArgumentOutOfRangeException - The Status value specified is invalid.
Default = OracleParameterStatus.Success
Status indicates whether:
NULL is fetched from a column; then Value is an empty string.
Value is not big enough to hold the data.
NULL is to be inserted into a database column; then Value is ignored, and a NULL is inserted into a database column.
This property specifies the value of the Parameter.
// C# public object Value { get; set; }
An object.
IDataParameter
ArgumentException - The Value property specified is invalid.
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.
For input parameters the value is:
OracleCommand that is sent to the server.
OracleDbType or DbType when the provider sends the data to the server.
For output parameters the value is:
OracleCommand and after the OracleDataReader is closed (true for return value parameters also).
OracleDbType or DbType.
When array binding is used with:
Value should be set to an array of objects. ArrayBindCount should be set to a value that is greater than zero to indicate the number of elements to be bound.
ArrayBindCount should be set to a value that is greater than zero to indicate the number of elements to be retrieved (for SELECT statements).
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.
OracleParameter public methods are listed in Table 4-93.
This method creates a copy of an OracleParameter object.
// C# public object Clone();
An OracleParameter object.
ICloneable
The cloned object has the same property values as that of the object being cloned.
// C# ... //Need a proper casting for the return value when cloned OracleParameter param_cloned = (OracleParameter) param.Clone(); ...
This method releases resources allocated for an OracleParameter object.
// C# public void Dispose();
IDisposable
|
|
![]() Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|