| Oracle C++ Call Interface Programmer's Guide Release 2 (9.2) Part Number A96583-01 |
|
OCCI Classes and Methods, 11 of 22
IntervalYM supports the SQL92 datatype Year-Month Interval.
Leading field precision will be determined by number of decimal digits on input.
IntervalYM(const Environment *env, int year = 0, int month=0);
Valid values are -10^9 through 10^9
Valid values are -11 through 11
Constructs a null IntervalYM object. A null intervalYM can be initialized by assignment or calling fromText method. Methods that can be called on null intervalYM objects are setNull and isNull.
IntervalYM();
Constructs an IntervalYM object from src.
IntervalYM(const IntervalYM &src);
The following code example demonstrates that the default constructor creates a null value, and how you can assign a non null value to a year-month interval and then perform operations on it:
Environment *env = Environment::createEnvironment(); //create a null year-month interval IntervalYM ym if(ym.isnull()) cout << "\n ym is null"; //assign a non null value to ym IntervalYM anotherYM(env, "10-30"); ym = anotherYM; //now all operations are valid on ym... int yr = ym.getYear();
The following code example demonstrates how to get the year-month interval column from a result set, add to the year-month interval by using the += operator, multiply by using the * operator, compare 2 year-month intervals, and convert a year-month interval to a string by using the toText method:
//SELECT WARRANT_PERIOD from PRODUCT_INFORMATION //obtain result set resultset->next(); //get interval value from resultset IntervalYM ym1 = resultset->getIntervalYM(1); IntervalYM addWith(env, 10, 1); ym1 += addWith; //call += operator IntervalYM mulYm1 = ym1 * Number(env, 10); //call * operator if(ym1<mulYm1) //comparison . . .; string strym = ym1.toText(3); //3 is the leading field precision
This method initializes the interval to the values in inpstr. The string is interpreted using the nls parameters set in the environment.
The nls parameters are picked up from env. If env is null, the nls parameters are picked up from the environment associated with the instance, if any.
void fromText(const string &inpstr,
const string &nlsParam = "",
const Environment *env = NULL);
Input string representing a year month interval of the form `year-month'.
This parameter is currently not used.
The environment whose nls parms will be used.
This method returns the month component of the interval.
int getMonth() const;
This method returns the year component of the interval.
int getYear() const;
This method tests whether the interval is null. If the interval is null then true is returned; otherwise, false is returned.
bool isNull() const;
This method multiplies the interval by a factor and returns the result.
const IntervalYM operator*(const IntervalDS &a
const Number &factor);
Interval to be multiplied.
Factor by which the interval is to be multiplied.
This method multiplies the interval by a factor.
Syntax
IntervalYM& operator*=(const Number &factor);
Factor by which the interval is to be multiplied.
This method assigns the specified value to the interval.
const IntervalYM& operator=(const IntervalYM &src);
A year month interval.
This method compares the intervals specified. If the intervals are equal then true is returned; otherwise, false is returned. If either interval is null then SQLException is thrown.
bool operator==(const IntervalYM &a,
const IntervalYM &b);
Intervals to be compared.
This method compares the intervals specified. If the intervals are not equal then true is returned; otherwise, false is returned. If either interval is null then SQLException is thrown.
bool operator!=(const IntervalYM &a, const IntervalYM &b);
Intervals to be compared.
This method returns the result of dividing the interval by a factor.
const IntervalYM operator/(const IntervalYM &a,
const Number &factor);
Interval to be divided.
Factor by which the intreval is to be divided.
This method divides the interval by a factor.
IntervalYM& operator/=(const Number &a);
Factor by which the interval is to be divided.
This method compares the intervals specified. If the first interval is greater than the second interval then true is returned; otherwise, false is returned. If either interval is null then SQLException is thrown.
bool operator>(const IntervalYM &a,
const IntervalYM &b);
Intervals to be compared.
This method compares the intervals specified. If the first interval is greater than or equal to the second interval then true is returned; otherwise, false is returned. If either interval is null then SQLException is thrown.
bool operator>=(const IntervalYM &a, const IntervalYM &b);
Intervals to be compared.
This method compares the intervals specified. If the first interval is less than the second interval then true is returned; otherwise, false is returned. If either interval is null then SQLException is thrown.
bool operator<(const IntervalYM &a,
const IntervalYM &b);
Intervals to be compared.
This method compares the intervals specified. If the first interval is less than or equal to the second interval then true is returned; otherwise, false is returned. If either interval is null then SQLException is thrown
bool operator<=(const IntervalYM &a, const IntervalYM &b);
Intervals to be compared.
This method returns the difference between the intervals specified.
const IntervalYM operator-(const IntervalYM &a,
const IntervalYM &b);
Intervals to be compared.
This method computes the difference between itself and another interval.
IntervalYM& operator-=(const IntervalYM &a);
A year month interval.
This method returns the sum of the intervals specified.
const IntervalYM operator+(const IntervalYM &a,
const IntervalYM &b);
Intervals to be compared.
This method assigns the sum of IntervalYM and a to IntervalYM.
IntervalYM& operator+=(const IntervalYM &a);
This method sets the interval to the values specified.
void set(int year, int month);
Year component.
Valid values are -10^9 through 10^9.
month component.
Valid values are -11through 11.
This method sets the interval to null.
void setNull();
This method returns the string representation of the interval.
string toText(unsigned int lfprec, const string &nlsParam = "") const;
Leading field precision.
This parameter is not currently used.
|
![]() Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|