Type Definition odbc_api::parameter::VarCharSlice [−][src]
type VarCharSlice<'a> = VarChar<&'a [u8]>;
Binds a byte array as a VarChar input parameter.
While a byte array can provide us with a pointer to the start of the array and the length of the array itself, it can not provide us with a pointer to the length of the buffer. So to bind strings which are not zero terminated we need to store the length in a separate value.
This type is created if into_parameter
of the IntoParameter
trait is called on a &str
.
Example
use odbc_api::{Environment, IntoParameter}; let env = unsafe { Environment::new()? }; let mut conn = env.connect("YourDatabase", "SA", "<YourStrong@Passw0rd>")?; if let Some(cursor) = conn.execute( "SELECT year FROM Birthdays WHERE name=?;", &"Bernd".into_parameter())? { // Use cursor to process query results. };
Implementations
impl<'a> VarCharSlice<'a>
[src]
pub const NULL: Self
[src]
Indicates missing data
pub fn new(value: &'a [u8]) -> Self
[src]
Constructs a new VarChar containing the text in the specified buffer.
Caveat: This constructor is going to create a truncated value in case the input slice ends
with nul
. Should you want to insert an actual string those payload ends with nul
into
the database you need a buffer one byte longer than the string. You can instantiate such a
value using Self::from_buffer
.