pub trait ToSql {
// Required methods
fn oratype(&self, conn: &Connection) -> Result<OracleType>;
fn to_sql(&self, val: &mut SqlValue<'_>) -> Result<()>;
}
Expand description
Conversion from rust values to Oracle values.
The type of the Oracle value is determined by the rust type.
Rust Type | Oracle Type | Oracle Value |
---|---|---|
str , String | nvarchar2(length of the rust value) | The specified value |
i8 , i16 , i32 , i64 , isize , u8 , u16 , u32 , u64 , usize , f32 , f64 | number | The specified value |
Vec<u8> | raw(length of the rust value) | The specified value |
bool | boolean (PL/SQL only) | The specified value |
Timestamp | timestamp(9) with time zone | The specified value |
IntervalDS | interval day(9) to second(9) | The specified value |
IntervalYM | interval year(9) to month | The specified value |
Collection | type returned by Collection::object_type | The specified value |
Object | type returned by Object::object_type | The specified value |
VecRef | vector | |
Option<T> where T: ToSql + ToSqlNull | When the value is Some , the contained value decides the Oracle type. When it is None , ToSqlNull decides it. | When the value is Some , the contained value. When it is None , a null value. |
OracleType | type represented by the OracleType. | a null value |
(&ToSql, &OracleType) | type represented by the second element. | The value of the first element |
When you need to bind output parameters such as varchar2, use OracleType
or (&ToSql, &OracleType)
to specify the maximum length of data types.
When chrono
feature is enabled, the following conversions are added.
Rust Type | Oracle Type |
---|---|
chrono::Date | timestamp(0) with time zone |
chrono::DateTime | timestamp(9) with time zone |
chrono::naive::NaiveDate | timestamp(0) |
chrono::naive::NaiveDateTime | timestamp(9) |
chrono::Duration , which is alias of chrono::TimeDelta since chrono 0.4.43 ] | interval day(9) to second(9) |
Required Methods§
fn oratype(&self, conn: &Connection) -> Result<OracleType>
fn to_sql(&self, val: &mut SqlValue<'_>) -> Result<()>
Implementations on Foreign Types§
Source§impl ToSql for NaiveDateTime
Available on crate feature chrono
only.
impl ToSql for NaiveDateTime
Available on crate feature
chrono
only.