Skip Headers

Oracle® C++ Call Interface Programmer's Guide
10g Release 1 (10.1)

Part Number B10778-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
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

IntervalDS Class

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);

Table 10-16 Fields of IntervalDS Class

Field Type Description
day int Day component. Valid values are -10^9 through 10^9.
hour int Hour component. Valid values are -23 through 23.
minute int Minute component. Valid values are -59 through 59.
second int Second component. Valid values are -59 through 59.
fs int 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 setName() and isNull().

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 on IntervalDS are valid
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

Table 10-17 Summary of IntervalDS Methods

Method Summary
IntervalDS()
IntervalDS class constructor.
fromText()
Return an IntervalDS with the value represented by instring.
getDay()
Return day interval values.
getFracSec()
Return fractional second interval values.
getFracSec()
Return hour interval values.
getMinute()
Return minute interval values.
getSecond()
Return second interval values.
isNull()
Return true if IntervalDS is NULL, false otherwise.
operator*()
Return the product of two IntervalDS values.
operator*=()
Multiplication assignment.
operator=()
Simple assignment.
operator==()
Check if a and b are equal.
operator!=()
Check if a and b are not equal.
operator==()
Return an IntervalDS with value (a / b).
operator/=()
Division assignment.
operator>()
Check if a is greater than b
operator>=()
Check if a is greater than or equal to b.
operator<()
Check if a is less than b.
operator>()
Check if a is less than or equal to b.
operator>()
Return an IntervalDS with value (a - b).
-=
Subtraction assignment.
operator+()
Return the sum of two IntervalDS values.
operator+=()
Addition assignment.
getDay()
Set day-second interval.
setName()
Set day-second interval to NULL.
operator=()
Return string representation for the interval.


IntervalDS()

IntervalDS class constructor.

Syntax Description
IntervalDS();
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 setName() and isNull().
IntervalDS(
   const IntervalDS &src);
Constructs an IntervalYM object from src.

Parameter Description
scp
The source that the IntervalDS object will be copied from.


fromText()

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.


Syntax
void fromText(
   const string &inpStr,
   const string &nlsParam = "",
   const Environment *env = NULL);
Parameter Description
inpStr
Input string representing a day second interval of the form 'days hours:minutes:seconds', for example, '10 20:14:10.2'
nlsParam
The nls parameters string. If nlsParam is specified, this determines the nls parameters to be used for the conversion. If nlsParam is not specified, the nls parameters are picked up from envp.
env
Environment whose nls parameters will be used.


getDay()

Returns the day component of the interval.


Syntax
int getDay() const;


getFracSec()

Returns the fractional second component of the interval.


Syntax
int getFracSec() const;


getHour()

Returns the hour component of the interval.


Syntax
int getHour() const;


getMinute()

Returns the minute component of this interval.


Syntax
int getMinute() const;


getSecond()

Returns the seconds component of this interval.


Syntax
int getSecond() const;


isNull()

Tests whether the interval is NULL. If the interval is NULL then TRUE is returned; otherwise, FALSE is returned.


Syntax
bool isNull() const;


operator*()

Multiplies an interval by a specified value and returns the result.


Syntax
const IntervalDS operator*(
   const IntervalDS &interval,
   const Number &val);
Parameter Description
interval
Interval to be multiplied.
val
Value by which interval is to be multiplied.


operator*=()

Assigns the product of IntervalDS and a to IntervalDS.


Syntax
IntervalDS& operator*=(
   const IntervalDS &val);
Parameter Description
val
A day second interval.


operator=()

Assigns the specified value to the interval.


Syntax
IntervalDS& operator=(
   const IntervalDS &val);
Parameter Description
val
Value to be assigned.


operator==()

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.


Syntax
bool operator==(
   const IntervalDS &first,
   const IntervalDS &second);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator!=()

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.


Syntax
bool operator!=(
   const IntervalDS &first,
   const IntervalDS &second);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator/()

Returns the result of dividing an interval by a constant value.


Syntax
const IntervalDS operator/(
   const IntervalDS &dividend,
   const Number &factor);
Parameter Description
dividend
The interval to be divided.
factor
Value by which interval is to be divided.


operator/=()

Assigns the quotient of IntervalDS and val to IntervalDS.


Syntax
IntervalDS& operator/=(
   const IntervalDS &val);
Parameter Description
val
A day second interval.


operator>()

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.


Syntax
bool operator>(
   const IntervalDS &first,
   const IntervalDS &second);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator>=()

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.


Syntax
bool operator>=(
   const IntervalDS &first,
   const IntervalDS &first);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator<()

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.


Syntax
bool operator<(
   const IntervalDS &first,
   const IntervalDS &second);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator<=()

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.


Syntax
bool operator<=(
   const IntervalDS &first,
   const IntervalDS &second);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator-()

Returns the difference between the intervals first and second.


Syntax
const IntervalDS operator-(
   const IntervalDS &first,
   const IntervalDS &second);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator-=()

Assigns the difference between IntervalDS and val to IntervalDS.


Syntax
IntervalDS& operator-=(
   const IntervalDS &val);
Parameter Description
val
A day second interval.


operator+()

Returns the sum of the intervals specified.


Syntax
const IntervalDS operator+(
   const IntervalDS &first,
   const IntervalDS &second);
Parameter Description
first
The first interval to be compared.
second
The second interval to be compared.


operator+=()

Assigns the sum of IntervalDS and val to IntervalDS.


Syntax
IntervalDS& operator+=(
   const IntervalDS &val);
Parameter Description
val
A day second interval.


set()

Sets the interval to the values specified.


Syntax
void set(
   int day,
   int hour,
   int minute,
   int second,
   int fracsec);
Parameter Description
day
Day component.
hour
Hour component.
min
Minute component.
second
Second component.
fracsec
Fractional second component.


setNull()

Sets the IntervalDS to NULL.


Syntax
void setNull();


toText()

Returns the string representation for the interval.


Syntax
string toText(
   unsigned int lfPrec,
   unsigned int fsPrec,
   const string &nlsParam = "") const;
Parameter Description
lfPrec
Leading field precision.
fsPrec
Fractional second precision.
nlsParam
The nls parameters string. If nlsParam is specified, this determines the nls parameters to be used for the conversion. If nlsParam is not specified, the nls parameters are picked up from envp.