Skip Headers
Oracle® C++ Call Interface Programmer's Guide,
11g Release 2 (11.2)

Part Number E10764-02
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
LNCPP1011

IntervalDS Class

The IntervalDS class encapsulates time interval calculations in terms of days, hours, minutes, seconds, and fractional seconds. Leading field precision is determined by number of decimal digits in day input. Fraction second precision is determined by number of fraction digits on input.

LNCPP21003Table 13-19 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().


LNCPP21004Example 13-6 How to Use an Empty IntervalDS Object through Direct Assignment

This example demonstrates how 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();

LNCPP21005Example 13-7 How to Use an Empty IntervalDS Object Through *Text() Methods

This 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

LNCPP21006Table 13-20 Summary of IntervalDS Methods

Method Summary

IntervalDS()

IntervalDS class constructor.

fromText()

Returns an IntervalDS converted from a string.

fromUText()

Returns an IntervalDS converted from a UString.

getDay()

Returns day interval values.

getFracSec()

Returns fractional second interval values.

getFracSec()

Returns hour interval values.

getMinute()

Returns minute interval values.

getSecond()

Returns second interval values.

isNull()

Returns true if IntervalDS is NULL, false otherwise.

operator*()

Returns the product of two IntervalDS values.

operator*=()

Multiplication assignment.

operator=()

Simple assignment.

operator==()

Checks if a and b are equal.

operator!=()

Checks if a and b are not equal.

operator/()

Returns an IntervalDS with value (a / b).

operator/=()

Division assignment.

operator>()

Checks if a is greater than b

operator>=()

Checks if a is greater than or equal to b.

operator<()

Checks if a is less than b.

operator<=()

Checks if a is less than or equal to b.

operator-()

Returns an IntervalDS with value (a - b).

-=

Subtraction assignment.

operator+()

Returns the sum of two IntervalDS values.

operator+=()

Addition assignment.

set()

Sets day-second interval.

setNull()

Sets day-second interval to NULL.

toText()

Converts to a string representation for the interval.

toUText()

Converts to a UString representation for the interval.


LNCPP21007

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 Environment *env,
   int day = 0,
   int hour = 0,
   int minute = 0,
   int second = 0,
   int fs = 0);
Constructs an IntervalDS object within a specified Environment.
IntervalDS(
   const IntervalDS &src);
Constructs an IntervalYM object from src.

Parameter Description
env
The Environment.
day
The day field of IntervalDS.
hour
The hour field of IntervalDS.
minute
The minute field of IntervalDS.
second
The second field of IntervalDS.
fs
The fs field of IntervalDS.
src
The source that the IntervalDS object is copied from.

LNCPP21008

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.

LNCPP21009Syntax

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 parameter 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 are used.

LNCPP21010

fromUText()

Creates the interval from the UString specified.

LNCPP21011Syntax

void fromUText(
   const UString &inpstr,
   const Environment *env=NULL );
Parameter Description
inpstr
Input UString representing a day second interval of the form 'days hours:minutes:seconds', for example, '10 20:14:10.2'
env
The Environment.

LNCPP21012

getDay()

Returns the day component of the interval.

LNCPP21013Syntax

int getDay() const;
LNCPP21014

getFracSec()

Returns the fractional second component of the interval.

LNCPP21015Syntax

int getFracSec() const;
LNCPP21016

getHour()

Returns the hour component of the interval.

LNCPP21017Syntax

int getHour() const;
LNCPP21018

getMinute()

Returns the minute component of this interval.

LNCPP21019Syntax

int getMinute() const;
LNCPP21020

getSecond()

Returns the seconds component of this interval.

LNCPP21021Syntax

int getSecond() const;
LNCPP21022

isNull()

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

LNCPP21023Syntax

bool isNull() const;
LNCPP21024

operator*()

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

LNCPP21025Syntax

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.

LNCPP21026

operator*=()

Assigns the product of IntervalDS and a to IntervalDS.

LNCPP21027Syntax

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

LNCPP21028

operator=()

Assigns the specified value to the interval.

LNCPP21029Syntax

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

LNCPP21030

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.

LNCPP21031Syntax

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

LNCPP21032

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.

LNCPP21033Syntax

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

LNCPP21034

operator/()

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

LNCPP21035Syntax

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.

LNCPP21036

operator/=()

Assigns the quotient of IntervalDS and val to IntervalDS.

LNCPP21037Syntax

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

LNCPP21038

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.

LNCPP21039Syntax

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

LNCPP21040

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.

LNCPP21041Syntax

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

LNCPP21042

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.

LNCPP21043Syntax

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

LNCPP21044

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.

LNCPP21045Syntax

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

LNCPP21046

operator-()

Returns the difference between the intervals first and second.

LNCPP21047Syntax

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.

LNCPP21048

operator-=()

Assigns the difference between IntervalDS and val to IntervalDS.

LNCPP21049Syntax

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

LNCPP21050

operator+()

Returns the sum of the intervals specified.

LNCPP21051Syntax

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.

LNCPP21052

operator+=()

Assigns the sum of IntervalDS and val to IntervalDS.

LNCPP21053Syntax

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

LNCPP21054

set()

Sets the interval to the values specified.

LNCPP21055Syntax

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.

LNCPP21056

setNull()

Sets the IntervalDS to NULL.

LNCPP21057Syntax

void setNull();
LNCPP21058

toText()

Converts to a string representation for the interval.

LNCPP21059Syntax

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.

LNCPP21060

toUText()

Converts to a UString representation for the interval.

LNCPP21061Syntax

UString toUText(
   unsigned int lfprec,
   unsigned int fsprec) cosnt;
Parameter Description
lfprec
Leading field precision.
fsprec
Fractional second precision.

Reader Comment

   

Comments, corrections, and suggestions are forwarded to authors every week. By submitting, you confirm you agree to the terms and conditions. Use the OTN forums for product questions. For support or consulting, file a service request through My Oracle Support.

Hide Navigation

Quick Lookup

Database Library · Master Index · Master Glossary · Book List · Data Dictionary · SQL Keywords · Initialization Parameters · Advanced Search · Error Messages

Main Categories

This Page

This Document

New and changed documents:
RSS Feed HTML RSS Feed PDF