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

operator/=()

This method divides the interval by a factor.

Syntax

IntervalYM& operator/=(
const Number &factor);

Parameter

Description

factor

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 IntervalYM &first,
const IntervalYM &second);

Parameter

Description

first

The first interval to be compared.

second

The second interval 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 &first,
const IntervalYM &second);

Parameter

Description

first

The first interval to be compared.

second

The second interval 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 &first,
const IntervalYM &second);

Parameter

Description

first

The first interval to be compared.

second

The second interval 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