Oracle® Data Provider for .NET Developer's Guide 11g Release 1 (11.1) Part Number B28375-01 |
|
|
View PDF |
The OracleIntervalYM
structure represents the Oracle INTERVAL
YEAR
TO
MONTH
data type to be stored in or retrieved from a database. Each OracleIntervalYM
stores a period of time in years and months.
Class Inheritance
System.Object
System.ValueType
Oracle.DataAccess.Types.OracleIntervalYM
Declaration
// C# public struct OracleIntervalYM : 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 OracleIntervalYMSample { static void Main() { OracleIntervalYM iYMMax = OracleIntervalYM.MaxValue; double totalYears = iYMMax.TotalYears; totalYears -= 1; OracleIntervalYM iYMMax_1 = new OracleIntervalYM(totalYears); // Calculate the difference OracleIntervalYM iYMDiff = iYMMax - iYMMax_1; // Prints "iYMDiff.ToString() = +000000001-00" Console.WriteLine("iYMDiff.ToString() = " + iYMDiff.ToString()); } }
Requirements
Namespace: Oracle.DataAccess.Types
Assembly: Oracle.DataAccess.dll
Microsoft .NET Framework Version: 1.x or 2.0
See Also:
OracleIntervalYM
members are listed in the following tables:
OracleIntervalYM Constructors
OracleIntervalYM
constructors are listed in Table 12-61
Table 12-61 OracleIntervalYM Constructors
Constructor | Description |
---|---|
|
Instantiates a new instance of |
OracleIntervalYM Static Fields
The OracleIntervalYM
static fields are listed in Table 12-62.
Table 12-62 OracleIntervalYM Static Fields
Field | Description |
---|---|
Represents the maximum value for an |
|
Represents the minimum value for an |
|
Represents a null value that can be assigned to an |
|
Represents a zero value for an |
OracleIntervalYM Static Methods
The OracleIntervalYM
static methods are listed in Table 12-63.
Table 12-63 OracleIntervalYM Static Methods
Methods | Description |
---|---|
Determines whether or not two |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether two |
|
Returns an |
|
Returns a new instance of an |
OracleIntervalYM Static Operators
The OracleIntervalYM
static operators are listed in Table 12-64.
Table 12-64 OracleIntervalYM Static Operators
Operator | Description |
---|---|
Adds two |
|
Determines whether or not two |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether two |
|
Determines whether or not one |
|
Determines whether or not one |
|
Subtracts one |
|
Negates an |
|
Multiplies an |
|
Divides an |
OracleIntervalYM Type Conversions
The OracleIntervalYM
conversions are listed in Table 12-65.
Table 12-65 OracleIntervalYM Type Conversions
Operator | Description |
---|---|
Converts an |
|
Converts a string to an |
|
Converts the number of months to an |
OracleIntervalYM Properties
The OracleIntervalYM
properties are listed in Table 12-66.
Table 12-66 OracleIntervalYM Properties
Properties | Description |
---|---|
Returns an array of bytes that represents the Oracle |
|
Indicates whether or not the current instance has a null value |
|
Gets the months component of an |
|
Returns the total number, in years, that represents the period of time in the current |
|
Specifies the total number of months that is stored in the |
|
Gets the years component of an |
OracleIntervalYM Methods
The OracleIntervalYM
methods are listed in Table 12-67.
Table 12-67 OracleIntervalYM Methods
Methods | Description |
---|---|
Compares the current |
|
Determines whether or not the specified |
|
Returns a hash code for the |
|
GetType |
Inherited from |
Converts the current |
The OracleIntervalYM
constructors creates a new instance of the OracleIntervalYM
structure.
Overload List:
This method creates a new instance of the OracleIntervalYM
structure using the supplied total number of months for a period of time.
This method creates a new instance of the OracleIntervalYM
structure and sets its value using the supplied string.
This method creates a new instance of the OracleIntervalYM
structure and sets its value using the total number of years.
This method creates a new instance of the OracleIntervalYM
structure and sets its value using years and months.
This method creates a new instance of the OracleIntervalYM
structure and sets its value to the provided byte array, which is in an internal Oracle INTERVAL
DAY
TO
SECOND
format.
This method creates a new instance of the OracleIntervalYM
structure using the supplied total number of months for a period of time.
Declaration
// C#
public OracleIntervalYM (long totalMonths);
Parameters
totalMonths
The number of total months for a time interval. Range is -12,000,000,000 < totalMonths
< 12,000,000,000.
Exceptions
ArgumentOutOfRangeException
- The totalMonths
parameter is out of the specified range.
This method creates a new instance of the OracleIntervalYM
structure and sets its value using the supplied string.
Declaration
// C#
public OracleIntervalYM (string intervalStr);
Parameters
intervalStr
A string representing the Oracle INTERVAL
YEAR
TO
MONTH
.
Remarks
The value specified in the supplied intervalStr
must be in Year-Month format.
Exceptions
ArgumentException
- The intervalStr
parameter is not in the valid format or intervalStr
has an invalid value.
ArgumentNullException
- The intervalStr
parameter is null.
Example
"1-2" means 1 year and 2 months.
This method creates a new instance of the OracleIntervalYM
structure and sets its value using the total number of years.
Declaration
// C#
public OracleIntervalYM (double totalYears);
Parameters
totalYears
Number of total years. Range is -1,000,000,000 < totalYears
> 1,000,000,000.
Exceptions
ArgumentOutOfRangeException
- The totalYears
parameter is out of the specified range.
ArgumentException
- The totalYears
parameter cannot be used to construct a valid OracleIntervalYM
.
This method creates a new instance of the OracleIntervalYM
structure and sets its value using years and months.
Declaration
// C# public OracleIntervalYM (int years, int months);
Parameters
years
Number of years. Range of year is (-999,999,999 to 999,999,999).
months
Number of months. Range of month is (-11 to 11).
Remarks
The sign of all the arguments must be the same.
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 OracleIntervalYM
.
This method creates a new instance of the OracleIntervalYM
structure and sets its value to the provided byte array, which is in an internal Oracle INTERVAL
DAY
TO
SECOND
format.
Declaration
// C#
public OracleIntervalYM (byte[] bytes);
Parameters
bytes
A byte array that is in an internal Oracle INTERVAL
YEAR
TO
MONTH
format.
Exceptions
ArgumentException
- The supplied byte array is not in an internal Oracle INTERVAL
YEAR
TO
MONTH
format or the supplied byte array has an invalid value.
ArgumentNullException
- bytes
is null.
Remarks
The supplied byte array must be in an internal Oracle INTERVAL
YEAR
TO
MONTH
format.
The OracleIntervalYM
static fields are listed in Table 12-68.
Table 12-68 OracleIntervalYM Static Fields
Field | Description |
---|---|
Represents the maximum value for an |
|
Represents the minimum value for an |
|
Represents a null value that can be assigned to an |
|
Represents a zero value for an |
This static field represents the maximum value for an OracleIntervalYM
structure.
Declaration
// C# public static readonly OracleIntervalYM MaxValue;
Remarks
Year is 999999999 and Month is 11.
This static field represents the minimum value for an OracleIntervalYM
structure.
Declaration
// C# public static readonly OracleIntervalYM MinValue;
Remarks
Year is -999999999 and Month is -11.
This static field represents a null value that can be assigned to an OracleIntervalYM
instance.
Declaration
// C# public static readonly OracleIntervalYM Null;
This static field represents a zero value for an OracleIntervalYM
structure.
Declaration
// C# public static readonly OracleIntervalDS Zero;
The OracleIntervalYM
static methods are listed in Table 12-69.
Table 12-69 OracleIntervalYM Static Methods
Methods | Description |
---|---|
Determines whether or not two |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether two |
|
Returns an |
|
Returns a new instance of an |
This static method determines whether or not two OracleIntervalYM
values are equal.
Declaration
// C# public static bool Equals(OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
An OracleIntervalYM
structure.
val2
An OracleIntervalYM
structure.
Return Value
Returns true
if two OracleIntervalYM
values represent the same time interval, otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static method determines whether or not the first of two OracleIntervalYM
values is greater than the second.
Declaration
// C# public static bool GreaterThan(OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if the first of two OracleIntervalYM
values is greater than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static method determines whether or not the first of two OracleIntervalYM
values is greater than or equal to the second.
Declaration
// C# public static bool GreaterThanOrEqual(OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if the first of two OracleIntervalYM
values is greater than or equal to the second; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static method determines whether or not the first of two OracleIntervalYM
values is less than the second.
Declaration
// C# public static bool LessThan(OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if the first of two OracleIntervalYM
values is less than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static method determines whether or not the first of two OracleIntervalYM
values is less than or equal to the second.
Declaration
// C# public static bool LessThanOrEqual(OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if the first of two OracleIntervalYM
values is less than or equal to the second. Returns false
otherwise.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static method determines whether two OracleIntervalYM
values are not equal.
Declaration
// C# public static bool NotEquals(OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if two OracleIntervalYM
values are not equal. Returns false
otherwise.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static method returns an OracleIntervalYM
structure and sets its value for time interval using a string.
Declaration
// C#
public static OracleIntervalYM Parse (string intervalStr);
Parameters
intervalStr
A string representing the Oracle INTERVAL
YEAR
TO
MONTH
.
Return Value
Returns an OracleIntervalYM
structure.
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 the supplied intervalStr
must be in the Year-Month format.
Example
"1-2" means 1 year and 2 months.
This static method returns a new instance of an OracleIntervalYM
with the specified year precision.
Declaration
// C# public static OracleIntervalYM SetPrecision(OracleIntervalYM value1, int yearPrecision);
Parameters
value1
An OracleIntervalYM
structure.
yearPrecision
The year precision provided. Range of year precision is (0 to 9).
Return Value
An OracleIntervalDS
instance.
Exceptions
ArgumentOutOfRangeException
- yearPrecision
is out of the specified range.
Remarks
Depending on the value specified in the supplied yearPrecision
, 0
or more leading zeros are displayed in the string returned by ToString()
.
Example
An OracleIntervalYM
with a value of "1-2
" results in the string "001-2
" when SetPrecision()
is called with the year precision set to 3
.
The OracleIntervalYM
static operators are listed in Table 12-70.
Table 12-70 OracleIntervalYM Static Operators
Operator | Description |
---|---|
Adds two |
|
Determines whether or not two |
|
Determines whether or not one |
|
Determines whether or not one |
|
Determines whether two |
|
Determines whether or not one |
|
Determines whether or not one |
|
Subtracts one |
|
Negates an |
|
Multiplies an |
|
Divides an |
This static operator adds two OracleIntervalYM
values.
Declaration
// C# public static OracleIntervalYM operator + (OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
OracleIntervalYM
Remarks
If either argument has a null value, the returned OracleIntervalYM
structure has a null value.
This static operator determines if two OracleIntervalYM
values are equal.
Declaration
// C# public static bool operator == (OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if they are equal; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static operator determines if the first of two OracleIntervalYM
values is greater than the second.
Declaration
// C# public static bool operator > (OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if one OracleIntervalYM
value is greater than another; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static operator determines if the first of two OracleIntervalYM
values is greater than or equal to the second.
Declaration
// C# public static bool operator >= (OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if one OracleIntervalYM
value is greater than or equal to another; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static operator determines whether two OracleIntervalYM
values are not equal.
Declaration
// C# public static bool operator != (OracleIntervalYM val1, OracleIntervalYM val2)
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if two OracleIntervalYM
values are not equal; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static operator determines if the first of two OracleIntervalYM
values is less than the second.
Declaration
// C# public static bool operator < (OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if the first of two OracleIntervalYM
values is less than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static operator determines if the first of two OracleIntervalYM
values is less than or equal to the second.
Declaration
// C# public static bool operator <= (OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
Returns true
if the first of two OracleIntervalYM
values is less than or equal to the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
This static operator subtracts one OracleIntervalYM
structure from another.
Declaration
// C# public static OracleIntervalYM operator - (OracleIntervalYM val1, OracleIntervalYM val2);
Parameters
val1
The first OracleIntervalYM
.
val2
The second OracleIntervalYM
.
Return Value
An OracleIntervalYM
structure.
Remarks
If either argument has a null value, the returned OracleIntervalYM
structure has a null value.
This static operator negates an OracleIntervalYM
structure.
Declaration
// C#
public static OracleIntervalYM operator - (OracleIntervalYM val);
Parameters
val
An OracleIntervalYM
.
Return Value
An OracleIntervalYM
structure.
Remarks
If the supplied OracleIntervalYM
structure has a null value, the returned OracleIntervalYM
structure has a null value.
This static operator multiplies an OracleIntervalYM
value by a number.
Declaration
// C# public static OracleIntervalYM operator * (OracleIntervalYM val1, int multiplier);
Parameters
val1
The first OracleIntervalYM
.
multiplier
A multiplier.
Return Value
An OracleIntervalYM
structure.
Remarks
If the supplied OracleIntervalYM
structure has a null value, the returned OracleIntervalYM
structure has a null value.
This static operator divides an OracleIntervalYM
value by a number.
Declaration
// C#
public static OracleIntervalYM operator / (OracleIntervalYM val1, int divisor);
Parameters
val1
The first OracleIntervalYM
.
divisor
A divisor.
Return Value
An OracleIntervalYM
structure.
Remarks
If the supplied OracleIntervalYM
structure has a null value, the returned OracleIntervalYM
structure has a null value.
The OracleIntervalYM
conversions are listed in Table 12-71.
Table 12-71 OracleIntervalYM Type Conversions
Operator | Description |
---|---|
Converts an |
|
Converts a string to an |
|
Converts the number of months to an |
This type conversion operator converts an OracleIntervalYM
to a number that represents the number of months in the time interval.
Declaration
// C#
public static explicit operator long (OracleIntervalYM val);
Parameters
val
An OracleIntervalYM
structure.
Return Value
A long
number in months.
Exceptions
OracleNullValueException
- The OracleIntervalYM
structure has a null value.
This type conversion operator converts the string intervalStr
to an OracleIntervalYM
structure.
Declaration
// C#
public static explicit operator OracleIntervalYM (string intervalStr);
Parameters
intervalStr
A string representation of an Oracle INTERVAL
YEAR
TO
MONTH
.
Return Value
An OracleIntervalYM
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 Year-Month format.
This type conversion operator converts the total number of months as time interval to an OracleIntervalYM
structure.
Declaration
// C#
public static implicit operator OracleIntervalYM (long months);
Parameters
months
The number of months to be converted. Range is (-999,999,999 * 12)-11 <= months
<= (999,999,999 * 12)+11.
Return Value
An OracleIntervalYM
structure.
Exceptions
ArgumentOutOfRangeException
- The months
parameter is out of the specified range.
The OracleIntervalYM
properties are listed in Table 12-72.
Table 12-72 OracleIntervalYM Properties
Properties | Description |
---|---|
Returns an array of bytes that represents the Oracle |
|
Indicates whether or not the current instance has a null value |
|
Gets the months component of an |
|
Returns the total number, in years, that represents the period of time in the current |
|
Specifies the total number of months that is stored in the |
|
Gets the years component of an |
This property returns an array of bytes that represents the Oracle INTERVAL
YEAR
TO
MONTH
in Oracle internal format.
Declaration
// C# public byte[] BinData {get;}
Property Value
A byte array that represents an Oracle INTERVAL
YEAR
TO
MONTH
in Oracle internal format.
Exceptions
OracleNullValueException
- The current instance has a null value.
This property indicates whether or not the value has a null value.
Declaration
// C# public bool IsNull {get;}
Property Value
Returns true
if value has a null value; otherwise, returns false
.
This property gets the months component of an OracleIntervalYM.
Declaration
// C# public int Months {get;}
Property Value
An int
representing the months component.
Exceptions
OracleNullValueException
- The current instance has a null value.
This property returns the total number, in years, that represents the period of time in the current OracleIntervalYM
structure.
Declaration
// C# public double TotalYears {get;}
Property Value
A double
representing the total number of years.
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the total number of months that is stored in the OracleIntervalYM
structure.
Declaration
// C# public long Value {get;}
Property Value
The total number of months representing the time interval.
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the years component of an OracleIntervalYM
.
Declaration
// C# public int Years {get;}
Property Value
An int
representing the years component.
Exceptions
OracleNullValueException
- The current instance has a null value.
The OracleIntervalYM
methods are listed in Table 12-73.
Table 12-73 OracleIntervalYM Methods
Methods | Description |
---|---|
Compares the current |
|
Determines whether or not the specified |
|
Returns a hash code for the |
|
GetType |
Inherited from |
Converts the current |
This method compares the current OracleIntervalYM
instance to the supplied object, and returns an integer that represents their relative values.
Declaration
// C#
public int CompareTo(object obj);
Parameters
obj
The supplied object.
Return Value
The method returns a number:
Less than zero: if the current OracleIntervalYM
represents a shorter time interval than obj.
Zero: if the current OracleIntervalYM
and obj
represent the same time interval.
Greater than zero: if the current OracleIntervalYM
represents a longer time interval than obj.
Implements
IComparable
Exceptions
ArgumentException
- The obj
parameter is not of type OracleIntervalYM
.
Remarks
The following rules apply to the behavior of this method.
The comparison must be between OracleIntervalYM
s. For example, comparing an OracleIntervalYM
instance with an OracleBinary
instance is not allowed. When an OracleIntervalYM
is compared with a different type, an ArgumentException
is thrown.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
Overrides Object
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 supplied object.
Return Value
Returns true
if the specified object instance is of type OracleIntervalYM
and has the same time interval; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleIntervalYM
that has a value compares greater than an OracleIntervalYM
that has a null value.
Two OracleIntervalYM
s that contain a null value are equal.
Overrides Object
This method returns a hash code for the OracleIntervalYM
instance.
Declaration
// C# public override int GetHashCode();
Return Value
An int
representing a hash code.
Overrides Object
This method converts the current OracleIntervalYM
structure to a string.
Declaration
// C# public override string ToString();
Return Value
A string that represents the current OracleIntervalYM
structure.
Remarks
If the current instance has a null value, the returned string contain "null".