Skip Headers

Oracle C++ Call Interface Programmer's Guide
Release 2 (9.2)

Part Number A96583-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

OCCI Classes and Methods, 10 of 22


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

day

day component.

Valid values are -10^9 through 10^9.

hour

hour component.

Valid values are -23 through 23.

minute

minute component.

Valid values are -59 through 59.

second

second component.

Valid values are -59 through 59.

fs

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

Summary of IntervalDS Methods

Table 8-10 IntervalDS Methods  
Method Summary

fromText()

Return an IntervalDS with the value represented by instring.

getDay()

Return day interval values.

getFracSec()

Return fractional second interval values.

getHour()

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

operator-=()

Subtraction assignment.

operator+()

Return the sum of two IntervalDS values.

operator+=()

Addition assignment.

set()

Set day-second interval.

setNull()

Set day-second interval to null.

toText()

Return string representation for the interval.

fromText()

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.

Syntax
void fromText(const string &inpstr,
   const string &nlsParam = "",
   const Environment *env = NULL);
Parameters
inpstr

Input string representing a day second interval of the form 'days hours:minutes:seconds' for example, '10 20:14:10.2'

nlsParam

this parameter is not currently used.

env

Environemnt whose nls parameters is to be used.

getDay()

This method returns the day component of the interval.

Syntax
int getDay() const;

getFracSec()

This method returns the fractional second component of the interval.

Syntax
int getFracSec() const;

getHour()

This method returns the hour component of the interval.

Syntax
int getHour() const;

getMinute()

This method returns the minute component of this interval.

Syntax
int getMinute() const;

getSecond()

This method returns the seconds component of this interval.

Syntax
int getSecond() const;

isNull()

This method tests whether the interval is null. If the interval is null then true is returned; otherwise, false is returned.

Syntax
bool isNull() const;

operator*()

This method multiplies an interval by a factor and returns the result.

Syntax
const IntervalDS operator*(const IntervalDS &a,
   const Number &factor);
Parameters
a

Interval to be multiplied.

factor

Factor by which interval is to be multiplied.

operator*=()

This method assigns the product of IntervalDS and a to IntervalDS.

Syntax
IntervalDS& operator*=(const IntervalDS &a);
Parameters
a

A day second interval.

operator=()

This method assigns the specified value to the interval.

Syntax
IntervalDS& operator=(const IntervalDS &src);
Parameters
src

Value to be assigned.

operator==()

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.

Syntax
bool operator==(const IntervalDS &a,
   const IntervalDS &b);
Parameters
a,b

Intervals to be compared.

operator!=()

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.

Syntax
bool operator!=(const IntervalDS &a,
   const IntervalDS &b);
Parameters
a,b

Intervals to be compared.

operator/()

This method returns the result of dividing an interval by a constant factor.

Syntax
const IntervalDS operator/(const IntervalDS &a,
   const Number &factor);
Parameters
a

Interval to be divided

factor

factor by which interval is to be divided.

operator/=()

This method assigns the quotient of IntervalDS and a to IntervalDS.

Syntax
IntervalDS& operator/=(const IntervalDS &a);
Parameters
a

A day second interval.

operator>()

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.

Syntax
bool operator>(const IntervalDS &a,
   const IntervalDS &b);
Parameters
a,b

Intervals to be compared.

operator>=()

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.

Syntax
bool operator>=(const IntervalDS &a,
   const IntervalDS &b);
Parameter
a,b

Intervals to be compared.

operator<()

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.

Syntax
bool operator<(const IntervalDS &a,
   const IntervalDS &b);
Parameters
a,b

Intervals to be compared.

operator<=()

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.

Syntax
bool operator<=(const IntervalDS &a,
   const IntervalDS &b);
Parameters
a,b

Intervals to be compared.

operator-()

This method returns the difference between the intervals a and b.

Syntax
const IntervalDS operator-(const IntervalDS &a,
   const IntervalDS &b);
Parameters
a,b

Intervals to be compared.

operator-=()

This method assigns the difference between IntervalDS and a to IntervalDS.

Syntax
IntervalDS& operator-=(const IntervalDS &a);
Parameters
a

A day second interval.

operator+()

This method returns the sum of the intervals specified.

Syntax
const IntervalDS operator+(const IntervalDS &a,
   const IntervalDS &b);
Parameters
a,b

Intervals to be compared.

operator+=()

This method assigns the sum of IntervalDS and a to IntervalDS.

Syntax
IntervalDS& operator+=(const IntervalDS &a);
Parameters
a

A day second interval.

set()

This method sets the interval to the values specified.

Syntax
void set(int day,
   int hour,
   int minute,
   int second,
   int fracsec);
Parameters
day

Day component.

hour

Hour component.

minute

Minute component.

second

Second component.

fracsec

Fractional second component.

setNull()

This method sets the interval to null.

Syntax
void setNull();

toText()

This method returns the string representation for the interval.

Syntax
string toText(unsigned int lfprec,
   unsigned int fsprec,
   const string &nlsParam = "") const;
Parameters
lfprec

Leading field precision.

fsprec

Fractional second precision.

nlsParam

This parameter is not being used.


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2001, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback