[−][src]Struct oracle::sql_type::IntervalDS
Oracle-specific Interval Day to Second data type.
This struct doesn't have arithmetic methods and they won't be added to avoid
reinventing the wheel. If you need methods such as adding an interval to a
timestamp, enable chrono
feature and use chrono::Duration instead.
Examples
// Create an interval by new(). let intvl1 = IntervalDS::new(1, 2, 3, 4, 500000000); // All arguments must be zero or negative to create a negative interval. let intvl2 = IntervalDS::new(-1, -2, -3, -4, -500000000); // Convert to string. assert_eq!(intvl1.to_string(), "+000000001 02:03:04.500000000"); assert_eq!(intvl2.to_string(), "-000000001 02:03:04.500000000"); // Create an interval with leading field and fractional second precisions. let intvl3 = IntervalDS::new(1, 2, 3, 4, 500000000).and_prec(2, 3); // The string representation depends on the precisions. assert_eq!(intvl3.to_string(), "+01 02:03:04.500"); // Precisions are ignored when intervals are compared. assert!(intvl1 == intvl3); // Create an interval from string. let intvl4: IntervalDS = "+1 02:03:04.50".parse()?; // The precisions are determined by number of decimal digits in the string. assert_eq!(intvl4.lfprec(), 1); assert_eq!(intvl4.fsprec(), 2);
Fetch and bind interval values.
let conn = Connection::connect("scott", "tiger", "")?; // Fetch IntervalDS let sql = "select interval '+01 02:03:04.500' day to second(3) from dual"; let intvl = conn.query_row_as::<IntervalDS>(sql, &[])?; assert_eq!(intvl.to_string(), "+01 02:03:04.500"); // Bind IntervalDS let sql = "begin \ :outval := to_timestamp('2017-08-09', 'yyyy-mm-dd') + :inval; \ end;"; let mut stmt = conn.prepare(sql, &[])?; stmt.execute(&[&OracleType::Timestamp(3), // bind null as timestamp(3) &intvl, // bind the intvl variable ])?; let outval: Timestamp = stmt.bind_value(1)?; // get the first bind value. // 2017-08-09 + (1 day, 2 hours, 3 minutes and 4.5 seconds) assert_eq!(outval.to_string(), "2017-08-10 02:03:04.500");
Implementations
impl IntervalDS
[src]
pub fn new(
days: i32,
hours: i32,
minutes: i32,
seconds: i32,
nanoseconds: i32
) -> IntervalDS
[src]
days: i32,
hours: i32,
minutes: i32,
seconds: i32,
nanoseconds: i32
) -> IntervalDS
Creates a new IntervalDS.
Valid values are:
argument | valid values |
---|---|
days | -999999999 to 999999999 |
hours | -23 to 23 |
minutes | -59 to 59 |
seconds | -59 to 59 |
nanoseconds | -999999999 to 999999999 |
All arguments must be zero or positive to create a positive interval. All arguments must be zero or negative to create a negative interval.
pub fn and_prec(&self, lfprec: u8, fsprec: u8) -> IntervalDS
[src]
Creates a new IntervalDS with precisions.
lfprec
and fsprec
are leading field precision and fractional second
precision respectively.
The precisions affect text representation of IntervalDS.
They don't affect comparison.
pub fn days(&self) -> i32
[src]
Returns days component.
pub fn hours(&self) -> i32
[src]
Returns hours component.
pub fn minutes(&self) -> i32
[src]
Returns minutes component.
pub fn seconds(&self) -> i32
[src]
Returns seconds component.
pub fn nanoseconds(&self) -> i32
[src]
Returns nanoseconds component.
pub fn lfprec(&self) -> u8
[src]
Returns leading field precision.
pub fn fsprec(&self) -> u8
[src]
Returns fractional second precision.
Trait Implementations
impl Clone for IntervalDS
[src]
fn clone(&self) -> IntervalDS
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for IntervalDS
[src]
impl Debug for IntervalDS
[src]
impl Display for IntervalDS
[src]
impl FromSql for IntervalDS
[src]
fn from_sql(val: &SqlValue) -> Result<IntervalDS>
[src]
impl FromStr for IntervalDS
[src]
type Err = ParseOracleTypeError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl PartialEq<IntervalDS> for IntervalDS
[src]
impl ToSql for IntervalDS
[src]
fn oratype(&self, _conn: &Connection) -> Result<OracleType>
[src]
fn to_sql(&self, val: &mut SqlValue) -> Result<()>
[src]
impl ToSqlNull for IntervalDS
[src]
fn oratype_for_null(_conn: &Connection) -> Result<OracleType>
[src]
Auto Trait Implementations
impl RefUnwindSafe for IntervalDS
impl Send for IntervalDS
impl Sync for IntervalDS
impl Unpin for IntervalDS
impl UnwindSafe for IntervalDS
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<'a, T> TryFrom<&'a str> for T where
T: FromStr,
[src]
T: FromStr,
type Err = <T as FromStr>::Err
pub fn try_from(string: &'a str) -> Result<T, <T as TryFrom<&'a str>>::Err>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,