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

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

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

OracleIntervalYM Structure

The OracleIntervalYM structure represents the Oracle INTERVAL YEAR TO MONTH datatype to be stored in or retrieved from a database. Each OracleIntervalYM stores a period of time in years and months.

Class Inheritance

Object

  ValueType

    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


OracleIntervalYM Members

OracleIntervalYM members are listed in the following tables:

OracleIntervalYM Constructors

OracleIntervalYM constructors are listed in Table 11-61

Table 11-61 OracleIntervalYM Constructors

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

OracleIntervalYM Static Fields

The OracleIntervalYM static fields are listed in Table 11-62.

Table 11-62 OracleIntervalYM Static Fields

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

OracleIntervalYM Static Methods

The OracleIntervalYM static methods are listed in Table 11-63.

Table 11-63 OracleIntervalYM Static Methods

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

OracleIntervalYM Static Operators

The OracleIntervalYM static operators are listed in Table 11-64.

Table 11-64 OracleIntervalYM Static Operators

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

OracleIntervalYM Type Conversions

The OracleIntervalYM conversions are listed in Table 11-65.

Table 11-65 OracleIntervalYM Type Conversions

Operator Description
explicit operator long Converts an OracleIntervalYM structure to a number
explicit operator OracleIntervalYM Converts a string to an OracleIntervalYM structure
implicit operator OracleIntervalYM Converts the number of months to an OracleIntervalYM structure

OracleIntervalYM Properties

The OracleIntervalYM properties are listed in Table 11-66.

Table 11-66 OracleIntervalYM Properties

Properties Description
BinData Returns an array of bytes that represents the Oracle INTERVAL YEAR TO MONTH in an Oracle internal format
IsNull Indicates whether or not the current instance has a null value
Months Gets the months component of an OracleIntervalYM
TotalYears Returns the total number, in years, that represents the period of time in the current OracleIntervalYM structure
Value Specifies the total number of months that is stored in the OracleIntervalYM structure
Years Gets the years component of an OracleIntervalYM

OracleIntervalYM Methods

The OracleIntervalYM methods are listed in Table 11-67.

Table 11-67 OracleIntervalYM Methods

Methods Description
CompareTo Compares the current OracleIntervalYM instance to the supplied 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 OracleIntervalYM instance
GetType Inherited from Object
ToString Converts the current OracleIntervalYM structure to a string


OracleIntervalYM Constructors

The OracleIntervalYM constructors creates a new instance of the OracleIntervalYM structure.

Overload List:

OracleIntervalYM(long)

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

Exceptions

ArgumentOutOfRangeException - The totalMonths parameter is out of the specified range.

OracleIntervalYM(string)

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

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.

OracleIntervalYM(double)

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

Exceptions

ArgumentOutOfRangeException - The totalYears parameter is out of the specified range.

ArgumentException - The totalYears parameter cannot be used to construct a valid OracleIntervalYM.

OracleIntervalYM(int, int)

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

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.

OracleIntervalYM(byte[ ])

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

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.


OracleIntervalYM Static Fields

The OracleIntervalYM static fields are listed in Table 11-68.

Table 11-68 OracleIntervalYM Static Fields

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

MaxValue

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.

MinValue

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.

Null

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

Declaration

// C#
public static readonly OracleIntervalYM Null;

Zero

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

Declaration

// C#
public static readonly OracleIntervalDS Zero;

OracleIntervalYM Static Methods

The OracleIntervalYM static methods are listed in Table 11-69.

Table 11-69 OracleIntervalYM Static Methods

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

Equals

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

Declaration

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

Parameters

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.

GreaterThan

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

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.

GreaterThanOrEqual

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

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.

LessThan

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

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.

LessThanOrEqual

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

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.

NotEquals

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

Declaration

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

Parameters

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.

Parse

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

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.

SetPrecision

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

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.


OracleIntervalYM Static Operators

The OracleIntervalYM static operators are listed in Table 11-70.

Table 11-70 OracleIntervalYM Static Operators

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

operator +

This static operator adds two OracleIntervalYM values.

Declaration

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

Parameters

Return Value

OracleIntervalYM

Remarks

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

operator ==

This static operator determines if two OracleIntervalYM values are equal.

Declaration

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

Parameters

Return Value

Returns true if they are equal; otherwise returns false.

Remarks

The following rules apply to the behavior of this method.

operator >

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

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.

operator >=

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

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.

operator !=

This static operator determines whether two OracleIntervalYM values are not equal.

Declaration

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

Parameters

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.

operator <

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

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.

operator <=

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

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.

operator -

This static operator subtracts one OracleIntervalYM structure from another.

Declaration

// C#
public static OracleIntervalYM operator - (OracleIntervalYM val1, OracleIntervalYM val2);

Parameters

Return Value

An OracleIntervalYM structure.

Remarks

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

operator -

This static operator negates an OracleIntervalYM structure.

Declaration

// C#
public static OracleIntervalYM operator - (OracleIntervalYM val);

Parameters

Return Value

An OracleIntervalYM structure.

Remarks

If the supplied OracleIntervalYM structure has a null value, the returned OracleIntervalYM structure has a null value.

operator *

This static operator multiplies an OracleIntervalYM value by a number.

Declaration

// C#
public static OracleIntervalYM operator * (OracleIntervalYM val1, int multiplier);

Parameters

Return Value

An OracleIntervalYM structure.

Remarks

If the supplied OracleIntervalYM structure has a null value, the returned OracleIntervalYM structure has a null value.

operator /

This static operator divides an OracleIntervalYM value by a number.

Declaration

// C#
public static OracleIntervalYM operator / (OracleIntervalYM val1, int divisor);

Parameters

Return Value

An OracleIntervalYM structure.

Remarks

If the supplied OracleIntervalYM structure has a null value, the returned OracleIntervalYM structure has a null value.


OracleIntervalYM Type Conversions

The OracleIntervalYM conversions are listed in Table 11-71.

Table 11-71 OracleIntervalYM Type Conversions

Operator Description
explicit operator long Converts an OracleIntervalYM structure to a number
explicit operator OracleIntervalYM Converts a string to an OracleIntervalYM structure
implicit operator OracleIntervalYM Converts the number of months to an OracleIntervalYM structure

explicit operator long

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

Return Value

A long number in months.

Exceptions

OracleNullValueException - The OracleIntervalYM structure has a null value.

explicit operator OracleIntervalYM

This type conversion operator converts the string intervalStr to an OracleIntervalYM structure.

Declaration

// C#
public static explicit operator OracleIntervalYM (string intervalStr);

Parameters

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.

implicit operator OracleIntervalYM

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

Return Value

An OracleIntervalYM structure.

Exceptions

ArgumentOutOfRangeException - The months parameter is out of the specified range.


OracleIntervalYM Properties

The OracleIntervalYM properties are listed in Table 11-72.

Table 11-72 OracleIntervalYM Properties

Properties Description
BinData Returns an array of bytes that represents the Oracle INTERVAL YEAR TO MONTH in an Oracle internal format
IsNull Indicates whether or not the current instance has a null value
Months Gets the months component of an OracleIntervalYM
TotalYears Returns the total number, in years, that represents the period of time in the current OracleIntervalYM structure
Value Specifies the total number of months that is stored in the OracleIntervalYM structure
Years Gets the years component of an OracleIntervalYM

BinData

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.

IsNull

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.

Months

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.

TotalYears

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.

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.

Years

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.


OracleIntervalYM Methods

The OracleIntervalYM methods are listed in Table 11-73.

Table 11-73 OracleIntervalYM Methods

Methods Description
CompareTo Compares the current OracleIntervalYM instance to the supplied 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 OracleIntervalYM instance
GetType Inherited from Object
ToString Converts the current OracleIntervalYM structure to a string

CompareTo

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

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.

Equals

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

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.

GetHashCode

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.

ToString

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