OCILIB (C and C++ Driver for Oracle)  4.1.0
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< IntervalTypeValuesIntervalType
 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
 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)
 Return a new Interval holding the sum of the current Interval value and the given Interval value.
 
Interval operator- (const Interval &other)
 Return a new Interval holding the difference of the current Interval value and the given Interval value.
 
Intervaloperator+= (const Interval &other)
 Increment the current Value with the given Interval value.
 
Intervaloperator-= (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 2880 of file ocilib.hpp.

Member Typedef Documentation

Interval types.

Possible values are Interval::IntervalTypeValues

Definition at line 2912 of file ocilib.hpp.

Member Enumeration Documentation

Interval types enumerated values.

Enumerator
YearMonth 

Interval unit range is months -> years

DaySecond 

Interval unit range is seconds -> days

Definition at line 2897 of file ocilib.hpp.

Constructor & Destructor Documentation

ocilib::Interval::Interval ( IntervalType  type)
inline

Create a new instance of the given type.

Parameters
type- Interval type to create

Definition at line 1952 of file ocilib_impl.hpp.

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

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 1957 of file ocilib_impl.hpp.

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

Member Function Documentation

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 1993 of file ocilib_impl.hpp.

References GetYearMonth().

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 2002 of file ocilib_impl.hpp.

References GetYearMonth(), and SetYearMonth().

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 2010 of file ocilib_impl.hpp.

References GetYearMonth().

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 2019 of file ocilib_impl.hpp.

References GetYearMonth(), and SetYearMonth().

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 2027 of file ocilib_impl.hpp.

References GetDaySecond().

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 2036 of file ocilib_impl.hpp.

References GetDaySecond(), and SetDaySecond().

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

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 2044 of file ocilib_impl.hpp.

References GetDaySecond().

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 2053 of file ocilib_impl.hpp.

References GetDaySecond(), and SetDaySecond().

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 2061 of file ocilib_impl.hpp.

References GetDaySecond().

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 2070 of file ocilib_impl.hpp.

References GetDaySecond(), and SetDaySecond().

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 2078 of file ocilib_impl.hpp.

References GetDaySecond().

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 2087 of file ocilib_impl.hpp.

References GetDaySecond(), and SetDaySecond().

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 2112 of file ocilib_impl.hpp.

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

Referenced by GetDay(), GetHours(), GetMilliSeconds(), GetMinutes(), GetSeconds(), SetDay(), SetHours(), SetMilliSeconds(), SetMinutes(), and SetSeconds().

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 2117 of file ocilib_impl.hpp.

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

Referenced by SetDay(), SetHours(), SetMilliSeconds(), SetMinutes(), and SetSeconds().

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 2122 of file ocilib_impl.hpp.

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

Referenced by GetMonth(), GetYear(), SetMonth(), and SetYear().

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 2126 of file ocilib_impl.hpp.

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

Referenced by SetMonth(), and SetYear().

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 2131 of file ocilib_impl.hpp.

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

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 2136 of file ocilib_impl.hpp.

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

Referenced by Interval().

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 2141 of file ocilib_impl.hpp.

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