[−][src]Struct oracle::sql_type::IntervalYM
Oracle-specific Interval Year to Month data type.
Examples
// Create an interval by new(). let intvl1 = IntervalYM::new(2, 3); // All arguments must be zero or negative to create a negative interval. let intvl2 = IntervalYM::new(-2, -3); // Convert to string. assert_eq!(intvl1.to_string(), "+000000002-03"); assert_eq!(intvl2.to_string(), "-000000002-03"); // Create an interval with precision. let intvl3 = IntervalYM::new(2, 3).and_prec(3); // The string representation depends on the precisions. assert_eq!(intvl3.to_string(), "+002-03"); // Precisions are ignored when intervals are compared. assert!(intvl1 == intvl3); // Create an interval from string. let intvl4: IntervalYM = "+002-3".parse()?; // The precision is determined by number of decimal digits in the string. assert_eq!(intvl4.precision(), 3);
Fetch and bind interval values.
let conn = Connection::connect("scott", "tiger", "")?; // Fetch IntervalYM let sql = "select interval '+02-03' year to month from dual"; let intvl = conn.query_row_as::<IntervalYM>(sql, &[])?; assert_eq!(intvl.to_string(), "+02-03"); // Bind IntervalYM let sql = "begin \ :outval := to_timestamp('2017-08-09', 'yyyy-mm-dd') + :inval; \ end;"; let mut stmt = conn.prepare(sql, &[])?; stmt.execute(&[&OracleType::Date, // bind null as date &intvl, // bind the intvl variable ])?; let outval: Timestamp = stmt.bind_value(1)?; // get the first bind value. // 2017-08-09 + (2 years and 3 months) assert_eq!(outval.to_string(), "2019-11-09 00:00:00");
Implementations
impl IntervalYM
[src]
pub fn new(years: i32, months: i32) -> IntervalYM
[src]
Creates a new IntervalYM.
Valid values are:
argument | valid values |
---|---|
years | -999999999 to 999999999 |
months | -11 to 11 |
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, precision: u8) -> IntervalYM
[src]
Creates a new IntervalYM with precision.
The precision affects text representation of IntervalYM. It doesn't affect comparison.
pub fn years(&self) -> i32
[src]
Returns years component.
pub fn months(&self) -> i32
[src]
Returns months component.
pub fn precision(&self) -> u8
[src]
Returns precision.
Trait Implementations
impl Clone for IntervalYM
[src]
fn clone(&self) -> IntervalYM
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for IntervalYM
[src]
impl Debug for IntervalYM
[src]
impl Display for IntervalYM
[src]
impl FromSql for IntervalYM
[src]
fn from_sql(val: &SqlValue) -> Result<IntervalYM>
[src]
impl FromStr for IntervalYM
[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<IntervalYM> for IntervalYM
[src]
impl ToSql for IntervalYM
[src]
fn oratype(&self, _conn: &Connection) -> Result<OracleType>
[src]
fn to_sql(&self, val: &mut SqlValue) -> Result<()>
[src]
impl ToSqlNull for IntervalYM
[src]
fn oratype_for_null(_conn: &Connection) -> Result<OracleType>
[src]
Auto Trait Implementations
impl RefUnwindSafe for IntervalYM
impl Send for IntervalYM
impl Sync for IntervalYM
impl Unpin for IntervalYM
impl UnwindSafe for IntervalYM
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>,