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, 11 of 22


IntervalYM Class

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

year

Valid values are -10^9 through 10^9

month

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

Summary of IntervalYM Methods

Table 8-11 IntervalYM Methods  
Method Summary

fromText()

Return an IntervalYM with the value represented by instring.

getMonth()

Return month interval value.

getYear()

Return year interval value.

isNull()

Check if the interval is null.

operator*()

Return the product of two IntervalYM 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 interval 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 interval with value (a - b).

operator-=()

Subtraction assignment.

operator+()

Return the sum of two IntervalYM values.

operator+=()

Addition assignment.

set()

Set the interval to the values specified.

setNull()

Set the interval to null.

toText()

Return the string representation of the interval.

fromText()

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.

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

Input string representing a year month interval of the form `year-month'.

nlsParam

This parameter is currently not used.

env

The environment whose nls parms will be used.

getMonth()

This method returns the month component of the interval.

Syntax
int getMonth() const;

getYear()

This method returns the year component of the interval.

Syntax
int getYear() 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 the interval by a factor and returns the result.

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

Interval to be multiplied.

factor

Factor by which the interval is to be multiplied.

operator*=()

This method multiplies the interval by a factor.

Syntax

IntervalYM& operator*=(const Number &factor);
Parameters
factor

Factor by which the interval is to be multiplied.

operator=()

This method assigns the specified value to the interval.

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

A year month interval.

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 IntervalYM &a,
   const IntervalYM &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 IntervalYM &a,
   const IntervalYM &b);
Parameters
a,b

Intervals to be compared.

operator/()

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

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

Interval to be divided.

factor

Factor by which the intreval is to be divided.

operator/=()

This method divides the interval by a factor.

Syntax
IntervalYM& operator/=(const Number &a);
Parameters
a

Factor by which the interval is to be divided.

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 IntervalYM &a,
   const IntervalYM &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 IntervalYM &a,
   const IntervalYM &b);
Parameters
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 IntervalYM &a,
   const IntervalYM &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 IntervalYM &a,
   const IntervalYM &b);
Parameters
a,b

Intervals to be compared.

operator-()

This method returns the difference between the intervals specified.

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

Intervals to be compared.

operator-=()

This method computes the difference between itself and another interval.

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

A year month interval.

operator+()

This method returns the sum of the intervals specified.

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

Intervals to be compared.

operator+=()

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

Syntax
IntervalYM& operator+=(const IntervalYM &a);

set()

This method sets the interval to the values specified.

Syntax
void set(int year,
   int month);
Parameters
year

Year component.

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

month

month component.

Valid values are -11through 11.

setNull()

This method sets the interval to null.

Syntax
void setNull();

toText()

This method returns the string representation of the interval.

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

Leading field precision.

nlsParam

This parameter is not currently 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