pub struct SqlValue { /* private fields */ }
Expand description
A type containing an Oracle value
When this is a column value in a select statement, the Oracle type is determined by the column type.
When this is a bind value in a SQL statement, the Oracle type is determined
by ToSql::oratype
.
Implementations§
source§impl SqlValue
impl SqlValue
sourcepub fn get<T>(&self) -> Result<T>where
T: FromSql,
pub fn get<T>(&self) -> Result<T>where
T: FromSql,
Gets the Oracle value. It internally does the followings:
- Checks whether the conversion from the Oracle type to the target rust type
is allowed. It returns
Err(Error::InvalidTypeConversion(...))
when it isn’t allowed. - Checks whether the Oracle value is null. When it is null and the return
type is
Option<FromSql>
, it returnsOk(None)
. When it is null and it isn’tOption<FromSql>
, it returnsErr(Error::NullValue)
. - Converts the Oracle value to the rust value. The data type is converted
implicitly if required. For example string is converted to i64 by
str::parse
ifget::<i64>()
is called forVARCHAR2
columns. If the conversion fails, various errors are returned.
sourcepub fn set(&mut self, val: &dyn ToSql) -> Result<()>
pub fn set(&mut self, val: &dyn ToSql) -> Result<()>
Sets a rust value to the Oracle value. It internally does the followings:
- Checks whether the conversion from the rust type to the target Oracle type
is allowed. It returns
Err(Error::InvalidTypeConversion(...))
when it isn’t allowed. - When the argument type is
None::<ToSql>
, null is set. - Otherwise, converts the rust value to the Oracle value. The data type
is converted implicitly if required. For example i64 is converted to
string by
to_string()
ifset(100i64)
is called forVARCHAR2
columns. When the argument isNone::<ToSql>
If the conversion fails, various errors are returned.
sourcepub fn is_null(&self) -> Result<bool>
pub fn is_null(&self) -> Result<bool>
Returns Ok(true)
when the SQL value is null. Ok(false)
when it isn’t null.
sourcepub fn oracle_type(&self) -> Result<&OracleType>
pub fn oracle_type(&self) -> Result<&OracleType>
Gets the Oracle type of the SQL value.
sourcepub fn dup(&self, _conn: &Connection) -> Result<SqlValue>
pub fn dup(&self, _conn: &Connection) -> Result<SqlValue>
Returns a duplicated value of self.