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
LNCPP1012

IntervalYM Class

IntervalYM supports the SQL standard data type Year-Month Interval.

Leading field precision is determined by number of decimal digits on input.

LNCPP21062Table 13-21 Fields of IntervalYM Class

Field Type Description

year

int

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

month

int

Month component. Valid values are -11 through 11.


LNCPP21063Example 13-8 How to Use an Empty IntervalYM Object Through Direct Assignment

This 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 on YM are valid
int yr = ym.getYear();

LNCPP21064Example 13-9 How to Use an IntervalYM Object Through ResultSet and toText() Method

This 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

LNCPP21065Table 13-22 Summary of IntervalYM Methods

Method Summary

IntervalYM()

IntervalYM class constructor.

fromText()

Converts a string into an IntervalYM.

fromUText()

Converts a UString into an IntervalYM.

getMonth()

Returns month interval value.

getYear()

Returns year interval value.

isNull()

Checks if the interval is NULL.

operator*()

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

operator-=()

Subtraction assignment.

operator+()

Returns the sum of two IntervalYM values.

operator+=()

Addition assignment.

set()

Sets the interval to the values specified.

setNull()

Sets the interval to NULL.

toText()

Converts to a string representation of the interval.

toUText()

Converts to a UString representation of the interval.


LNCPP21066

IntervalYM()

IntervalYM class constructor.

Syntax Description
IntervalYM();
Constructs a NULL IntervalYM object. A NULL IntervalYM can be initialized by assignment or calling operator*() method. Methods that can be called on NULL IntervalYM objects are setName() and isNull().
IntervalYM(
   const Environment *env,
   int year  = 0,
   int month = 0);
Creates an IntervalYM object within the specified Environment.
IntervalDS(
   const IntervalYM &src);
Copy constructor.

Parameter Description
env
The Environment.
year
The year field of the IntervalYM object.
month
The month field of the IntervalYM object.
src
The source that the IntervalYM object is copied from.

LNCPP21067

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.

LNCPP21068Syntax

void fromText(
   const string &inpStr,
   const string &nlsParam = "",
   const Environment *env = NULL);
Parameter Description
inpStr
Input string representing a year month interval of the form 'year-month'.
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 are used.

LNCPP21069

fromUText()

Creates the interval from the UString specified.

LNCPP21070Syntax

void fromUText(
   const UString &inpStr,
   const Environment *env=NULL );
Parameter Description
inpStr
Input UString representing a year month interval of the form 'year-month'.
env
The Environment.

LNCPP21071

getMonth()

This method returns the month component of the interval.

LNCPP21072Syntax

int getMonth() const;
LNCPP21073

getYear()

This method returns the year component of the interval.

LNCPP21074Syntax

int getYear() const;
LNCPP21075

isNull()

This method tests whether the interval is NULL. If the interval is NULL then TRUE is returned; otherwise, FALSE is returned.

LNCPP21076Syntax

bool isNull() const;
LNCPP21077

operator*()

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

LNCPP21078Syntax

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

LNCPP21079

operator*=()

This method multiplies the interval by a specified value.

Syntax

IntervalYM& operator*=(
   const Number &factor);
Parameter Description
factor
Value to be multiplied.

LNCPP21080

operator=()

This method assigns the specified value to the interval.

LNCPP21081Syntax

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

LNCPP21082

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.

LNCPP21083Syntax

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

LNCPP21084

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.

LNCPP21085Syntax

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

LNCPP21086

operator/()

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

LNCPP21087Syntax

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

LNCPP21088

operator/=()

This method divides the interval by a factor.

LNCPP21089Syntax

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

LNCPP21090

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.

LNCPP21091Syntax

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

LNCPP21092

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.

LNCPP21093Syntax

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

LNCPP21094

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.

LNCPP21095Syntax

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

LNCPP21096

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

LNCPP21097Syntax

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

LNCPP21098

operator-()

This method returns the difference between the intervals specified.

LNCPP21099Syntax

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

LNCPP21100

operator-=()

This method computes the difference between itself and another interval.

LNCPP21101Syntax

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

LNCPP21102

operator+()

This method returns the sum of the intervals specified.

LNCPP21103Syntax

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

LNCPP21104

operator+=()

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

LNCPP21105Syntax

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

LNCPP21106

set()

This method sets the interval to the values specified.

LNCPP21107Syntax

void set(
   int year,
   int month);
Parameter Description
year
Year component. Valid values are -10^9 through 10^9.
month
Month component. Valid values are -11 through 11.

LNCPP21108

setNull()

This method sets the interval to NULL.

LNCPP21109Syntax

void setNull();
LNCPP21110

toText()

This method returns the string representation of the interval.

LNCPP21111Syntax

string toText(
   unsigned int lfprec,
   const string &nlsParam = "") const;
Parameter Description
lfprec
Leading field 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.

LNCPP21112

toUText()

Converts to a UString representation for the interval.

LNCPP21113Syntax

UString toUText(
   unsigned int lfprec) cosnt;
Parameter Description
lfprec
Leading field 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