ocilib::Interval Class Reference

Object identifying the SQL data type INTERVAL. More...

`#include <ocilib.hpp>`

Inherits ocilib::HandleHolder< OCI_Interval *>, and ocilib::Streamable.

## Public Types

enum | IntervalTypeValues { YearMonth = OCI_INTERVAL_YM, DaySecond = OCI_INTERVAL_DS }
| Interval types enumerated values. More...
typedef Enum< IntervalTypeValues > | IntervalType
| Interval types. More...

## Public Member Functions

| Interval ()
| Create an empty null Interval instance.
| Interval (IntervalType type)
| Create a new instance of the given type. More...
| Interval (IntervalType type, const ostring &data)
| Create an interval object with the value provided by the input interval string. More...
IntervalType | GetType () const
| Return the type of the given interval object.
bool | IsValid () const
| Check if the given interval is valid.
int | GetYear () const
| Return the interval year value. More...
void | SetYear (int value)
| Set the interval year value. More...
int | GetMonth () const
| Return the interval month value. More...
void | SetMonth (int value)
| Set the interval month value. More...
int | GetDay () const
| Return the interval day value. More...
void | SetDay (int value)
| Set the interval day value. More...
int | GetHours () const
| Return the interval hours value. More...
void | SetHours (int value)
| Set the interval hours value. More...
int | GetMinutes () const
| Return the interval minutes value. More...
void | SetMinutes (int value)
| Set the interval minutes value. More...
int | GetSeconds () const
| Return the interval seconds value. More...
void | SetSeconds (int value)
| Set the interval seconds value. More...
int | GetMilliSeconds () const
| Return the interval seconds value.
void | SetMilliSeconds (int value)
| Set the interval milliseconds value.
void | GetDaySecond (int &day, int &hour, int &min, int &sec, int &fsec) const
| Extract the date / second parts from the interval value. More...
void | SetDaySecond (int day, int hour, int min, int sec, int fsec)
| Set the Day / Second parts. More...
void | GetYearMonth (int &year, int &month) const
| Extract the year / month parts from the interval value. More...
void | SetYearMonth (int year, int month)
| Set the Year / Month parts. More...
void | UpdateTimeZone (const ostring &timeZone)
| Update the interval value with the given time zone. More...
void | FromString (const ostring &data)
| Assign to the interval object the value provided by the input interval string. More...
ostring | ToString (int leadingPrecision, int fractionPrecision) const
| Convert the interval value to a string using the given precisions. More...
ostring | ToString () const override
| Convert the interval value to a string using the default precisions of 10.
Interval | Clone () const
| Clone the current instance to a new one performing deep copy.
Interval | operator+ (const Interval &other) const
| Return a new Interval holding the sum of the current Interval value and the given Interval value.
Interval | operator- (const Interval &other) const
| Return a new Interval holding the difference of the current Interval value and the given Interval value.
Interval & | operator+= (const Interval &other)
| Increment the current Value with the given Interval value.
Interval & | operator-= (const Interval &other)
| Decrement the current Value with the given Interval value.
bool | operator== (const Interval &other) const
| Indicates if the current Interval value is equal to the given Interval value.
bool | operator!= (const Interval &other) const
| Indicates if the current Interval value is not equal the given Interval value.
bool | operator> (const Interval &other) const
| Indicates if the current Interval value is superior to the given Interval value.
bool | operator< (const Interval &other) const
| Indicates if the current Interval value is inferior to the given Interval value.
bool | operator>= (const Interval &other) const
| Indicates if the current Interval value is superior or equal to the given Interval value.
bool | operator<= (const Interval &other) const
| Indicates if the current Interval value is inferior or equal to the given Interval value.

## Detailed Description

Object identifying the SQL data type INTERVAL.

This class wraps the OCILIB object handle OCI_Interval and its related methods

Definition at line 3113 of file ocilib.hpp.

## Member Typedef Documentation

## IntervalType

typedef Enum<IntervalTypeValues> ocilib::Interval::IntervalType

Interval types.

Possible values are Interval::IntervalTypeValues

Definition at line 3145 of file ocilib.hpp.

## Member Enumeration Documentation

## IntervalTypeValues

enum ocilib::Interval::IntervalTypeValues

Interval types enumerated values.

Enumerator
YearMonth | Interval unit range is months -> years
DaySecond | Interval unit range is seconds -> days

Definition at line 3130 of file ocilib.hpp.

## Constructor & Destructor Documentation

## Interval() [1/2]

ocilib::Interval::Interval | ( | IntervalType | type | ) |

inline

Create a new instance of the given type.

Parameters

  type | - Interval type to create

Definition at line 2319 of file ocilib_impl.hpp.

References ocilib::Check(), OCI_IntervalCreate(), and OCI_IntervalFree().

## Interval() [2/2]

ocilib::Interval::Interval | ( | IntervalType | type,
|  | const ostring & | data
| ) |  |

inline

Create an interval object with the value provided by the input interval string.

Parameters

  type | - Interval type to create
  data | - String interval

Note
  For interval format, refer to the Oracle SQL documentation

Definition at line 2324 of file ocilib_impl.hpp.

References ocilib::Check(), Interval(), OCI_IntervalCreate(), and OCI_IntervalFree().

## Member Function Documentation

## GetYear()

int ocilib::Interval::GetYear | ( |  | ) | const

inline

Return the interval year value.

Warning
  this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 2360 of file ocilib_impl.hpp.

## SetYear()

void ocilib::Interval::SetYear | ( | int | value | ) |

inline

Set the interval year value.

Warning
  this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 2369 of file ocilib_impl.hpp.

## GetMonth()

int ocilib::Interval::GetMonth | ( |  | ) | const

inline

Return the interval month value.

Warning
  this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 2377 of file ocilib_impl.hpp.

## SetMonth()

void ocilib::Interval::SetMonth | ( | int | value | ) |

inline

Set the interval month value.

Warning
  this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 2386 of file ocilib_impl.hpp.

## GetDay()

int ocilib::Interval::GetDay | ( |  | ) | const

inline

Return the interval day value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2394 of file ocilib_impl.hpp.

## SetDay()

void ocilib::Interval::SetDay | ( | int | value | ) |

inline

Set the interval day value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2403 of file ocilib_impl.hpp.

Referenced by ocilib::Timestamp::operator+(), ocilib::Timestamp::operator+=(), ocilib::Timestamp::operator-(), and ocilib::Timestamp::operator-=().

## GetHours()

int ocilib::Interval::GetHours | ( |  | ) | const

inline

Return the interval hours value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2411 of file ocilib_impl.hpp.

## SetHours()

void ocilib::Interval::SetHours | ( | int | value | ) |

inline

Set the interval hours value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2420 of file ocilib_impl.hpp.

## GetMinutes()

int ocilib::Interval::GetMinutes | ( |  | ) | const

inline

Return the interval minutes value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2428 of file ocilib_impl.hpp.

## SetMinutes()

void ocilib::Interval::SetMinutes | ( | int | value | ) |

inline

Set the interval minutes value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2437 of file ocilib_impl.hpp.

## GetSeconds()

int ocilib::Interval::GetSeconds | ( |  | ) | const

inline

Return the interval seconds value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2445 of file ocilib_impl.hpp.

## SetSeconds()

void ocilib::Interval::SetSeconds | ( | int | value | ) |

inline

Set the interval seconds value.

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2454 of file ocilib_impl.hpp.

## GetDaySecond()

void ocilib::Interval::GetDaySecond | ( | int & | day,
|  | int & | hour,
|  | int & | min,
|  | int & | sec,
|  | int & | fsec
| ) |  | const

inline

Extract the date / second parts from the interval value.

Parameters

  day | - Place holder for Day value
  hour | - Place holder for Hour value
  min | - Place holder for Minutes value
  sec | - Place holder for Seconds value
  fsec | - Place holder for Milliseconds value

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2479 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IntervalGetDaySecond().

## SetDaySecond()

void ocilib::Interval::SetDaySecond | ( | int | day,
|  | int | hour,
|  | int | min,
|  | int | sec,
|  | int | fsec
| ) |  |

inline

Set the Day / Second parts.

Parameters

  day | - Day value
  hour | - Hour value
  min | - Minutes value
  sec | - Seconds value
  fsec | - Milliseconds value

Warning
  this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 2484 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IntervalSetDaySecond().

## GetYearMonth()

void ocilib::Interval::GetYearMonth | ( | int & | year,
|  | int & | month
| ) |  | const

inline

Extract the year / month parts from the interval value.

Parameters

  year | - Place holder for year value
  month | - Place holder for month value

Warning
  this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 2489 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IntervalGetYearMonth().

## SetYearMonth()

void ocilib::Interval::SetYearMonth | ( | int | year,
|  | int | month
| ) |  |

inline

Set the Year / Month parts.

Parameters

  year | - Year value
  month | - Month value

Warning
  this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 2493 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IntervalSetYearMonth().

## UpdateTimeZone()

void ocilib::Interval::UpdateTimeZone | ( | const ostring & | timeZone | ) |

inline

Update the interval value with the given time zone.

Parameters

  timeZone | - Time zone name

Definition at line 2498 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IntervalFromTimeZone().

## FromString()

void ocilib::Interval::FromString | ( | const ostring & | data | ) |

inline

Assign to the interval object the value provided by the input interval string.

Parameters

  data | - String interval

Note
  For interval format, refer to the Oracle SQL documentation

Definition at line 2503 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IntervalFromText().

## ToString()

ostring ocilib::Interval::ToString | ( | int | leadingPrecision,
|  | int | fractionPrecision
| ) |  | const

inline

Convert the interval value to a string using the given precisions.

Parameters

  leadingPrecision | - leading precision
  fractionPrecision | - fraction precision

Definition at line 2508 of file ocilib_impl.hpp.

References ocilib::Check(), ocilib::MakeString(), and OCI_IntervalToText().