pub trait InputParameter: HasDataType + CElement { }
Expand description
Can be used to fill in a field value indicated by a placeholder (?
) then executing an SQL
statement.
§Supported input parameters
To bind a parameter its memory layout must be known to the ODBC driver. For some C-Types this is defined in the ODBC standard. Their rust equivalents are:
- f32
- f64
- i8
- i16
- i32
- i64
- u8
- u16
- u32
- u64
- Box
- CString
- CStr
Date
VarCharSlice
VarCharSliceMut
VarCharArray
VarCharBox
VarWCharSlice
VarWCharSliceMut
VarWCharBox
VarBinarySlice
VarBinarySliceMut
VarBinaryArray
VarBinaryBox
Some types have a memory layout known to the ODBC driver, but additional type information is
required to bind them as parameters. You can use these together with WithDataType
:
- Note that the you may need to set the desired precision in the ADR record of the statement
using a descriptor handle in order to bind a
Numeric
value which does not have scale0
. This is currently not supported in safe code. Consider binding large numeric values as Text.
§Support for idiomatic Rust types
Idomatic Rust types are supported through the IntoParameter
trait.
This trait can also be implemented for custom types in safe code.
Trait Implementations§
Source§impl CData for Box<dyn InputParameter>
impl CData for Box<dyn InputParameter>
Source§fn cdata_type(&self) -> CDataType
fn cdata_type(&self) -> CDataType
The identifier of the C data type of the value buffer. When it is retrieving data from the
data source with
fetch
, the driver converts the data to this type. When it sends data to
the source, the driver converts the data from this type.Source§fn indicator_ptr(&self) -> *const isize
fn indicator_ptr(&self) -> *const isize
Indicates the length of variable sized types. May be zero for fixed sized types. Used to
determine the size or existence of input parameters.
Source§fn value_ptr(&self) -> *const c_void
fn value_ptr(&self) -> *const c_void
Pointer to a value corresponding to the one described by
cdata_type
.Source§fn buffer_length(&self) -> isize
fn buffer_length(&self) -> isize
Maximum length of the type in bytes (not characters). It is required to index values in
bound buffers, if more than one parameter is bound. Can be set to zero for types not bound
as parameter arrays, i.e.
CStr
.Source§impl CElement for Box<dyn InputParameter>
impl CElement for Box<dyn InputParameter>
Source§fn assert_completness(&self)
fn assert_completness(&self)
Must panic if the parameter is not complete. I.e. the indicator of a variable length
parameter indicates a value larger than what is present in the value buffer. Read more