pub type VarCharSlice<'a> = VarChar<&'a [u8]>;
Expand description

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 = Environment::new()?;

let mut conn = env.connect("YourDatabase", "SA", "My@Test@Password1")?;
if let Some(cursor) = conn.execute(
    "SELECT year FROM Birthdays WHERE name=?;",
    &"Bernd".into_parameter())?
{
    // Use cursor to process query results.
};

Implementations

Indicates missing data

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.

Trait Implementations