Oracle C++ Call Interface Programmer's Guide Release 2 (9.2) Part Number A96583-01 |
|
OCCI Classes and Methods, 10 of 22
Leading field precision will be determined by number of decimal digits in day input. Fraction second precision will be determined by number of fraction digits on input.
IntervalDS(const Environment *env, int day = 0, int hour = 0, int minute = 0, int second = 0, int fs = 0);
day component.
Valid values are -10^9 through 10^9.
hour component.
Valid values are -23 through 23.
minute component.
Valid values are -59 through 59.
second component.
Valid values are -59 through 59.
fractional second component.
Constructs a null IntervalDS
object. A null intervalDS
can be initialized by assignment or calling fromText
method. Methods that can be called on null intervalDS
objects are setNull
and isNull
.
IntervalDS();
Constructs an IntervalDS object as a copy of an Interval reference.
IntervalDS(const Interval &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 day-second interval and then perform operations on it:
Environment *env = Environment::createEnvironment(); //create a null day-second interval IntervalDS ds; if(ds.isnull()) cout << "\n ds is null"; //assign a non null value to ds IntervalDS anotherDS(env, "10 20:14:10.2"); ds = anotherDS; //now all operations are valid on DS... int DAY = ds.getDay();
The following code example demonstrates how to create a null day-second interval, initialize the day-second interval by using the fromText
method, add to the day-second interval by using the += operator, multiply by using the * operator, compare 2 day-second intervals, and convert a day-second interval to a string by using the toText
method:
Environment *env = Environment::createEnvironment(); //create a null day-second interval IntervalDS ds1 //initialize a null day-second interval by using the fromText method ds1.fromText("20 10:20:30.9","",env); IntervalDS addWith(env,2,1); ds1 += addWith; //call += operator IntervalDS mulDs1=ds1 * Number(env,10); //call * operator if(ds1==mulDs1) //call == operator . . . string strds=ds1.toText(2,4); //2 is leading field precision //4 is the fractional field precision
This method creates the interval from the string specified. The string is converted using the nls parameters associated with the relevant 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 day second interval of the form 'days hours:minutes:seconds' for example, '10 20:14:10.2'
this parameter is not currently used.
Environemnt whose nls parameters is to be used.
This method returns the day component of the interval.
int getDay() const;
This method returns the fractional second component of the interval.
int getFracSec() const;
This method returns the hour component of the interval.
int getHour() const;
This method returns the minute component of this interval.
int getMinute() const;
This method returns the seconds component of this interval.
int getSecond() 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 an interval by a factor and returns the result.
const IntervalDS operator*(const IntervalDS &a,
const Number &factor
);
Interval to be multiplied.
Factor by which interval is to be multiplied.
This method assigns the product of IntervalDS
and a
to IntervalDS
.
IntervalDS& operator*=(const IntervalDS &a);
A day second interval.
This method assigns the specified value to the interval.
IntervalDS& operator=(const IntervalDS &src);
Value to be assigned.
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 IntervalDS &a,
const IntervalDS &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 IntervalDS &a, const IntervalDS &b);
Intervals to be compared.
This method returns the result of dividing an interval by a constant factor.
const IntervalDS operator/(const IntervalDS &a,
const Number &factor
);
Interval to be divided
factor by which interval is to be divided.
This method assigns the quotient of IntervalDS
and a
to IntervalDS
.
IntervalDS& operator/=(const IntervalDS &a);
A day second interval.
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 IntervalDS &a,
const IntervalDS &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 IntervalDS &a, const IntervalDS &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 IntervalDS &a,
const IntervalDS &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 IntervalDS &a, const IntervalDS &b);
Intervals to be compared.
This method returns the difference between the intervals a
and b
.
const IntervalDS operator-(const IntervalDS &a,
const IntervalDS &b
);
Intervals to be compared.
This method assigns the difference between IntervalDS
and a
to IntervalDS
.
IntervalDS& operator-=(const IntervalDS &a);
A day second interval.
This method returns the sum of the intervals specified.
const IntervalDS operator+(const IntervalDS &a,
const IntervalDS &b
);
Intervals to be compared.
This method assigns the sum of IntervalDS
and a
to IntervalDS
.
IntervalDS& operator+=(const IntervalDS &a);
A day second interval.
This method sets the interval to the values specified.
void set(int day, int hour, int minute, int second, int fracsec);
Day component.
Hour component.
Minute component.
Second component.
Fractional second component.
This method sets the interval to null.
void setNull();
This method returns the string representation for the interval.
string toText(unsigned int lfprec, unsigned int fsprec, const string &nlsParam = "") const;
Leading field precision.
Fractional second precision.
This parameter is not being used.
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|