odbc_api

Trait ParameterCollectionRef

Source
pub unsafe trait ParameterCollectionRef {
    // Required methods
    fn parameter_set_size(&self) -> usize;
    unsafe fn bind_parameters_to(
        &mut self,
        stmt: &mut impl Statement,
    ) -> Result<(), Error>;
}
Expand description

SQL Parameters used to execute a query.

ODBC allows to place question marks (?) in the statement text as placeholders. For each such placeholder a parameter needs to be bound to the statement before executing it.

§Examples

This trait is implemented by single parameters.

use odbc_api::{Environment, ConnectionOptions};

let env = Environment::new()?;

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

Tuples of Parameters implement this trait, too.

use odbc_api::{Environment, ConnectionOptions};

let env = Environment::new()?;

let mut conn = env.connect(
    "YourDatabase", "SA", "My@Test@Password1",
    ConnectionOptions::default()
)?;
let too_old = 1980;
let too_young = 2000;
if let Some(cursor) = conn.execute(
    "SELECT year, name FROM Birthdays WHERE ? < year < ?;",
    (&too_old, &too_young),
)? {
    // Use cursor to congratulate only persons in the right age group...
}

And so do array slices of Parameters.

use odbc_api::{Environment, ConnectionOptions};

let env = Environment::new()?;

let mut conn = env.connect(
    "YourDatabase",
    "SA",
    "My@Test@Password1",
    ConnectionOptions::default()
)?;
let params = [1980, 2000];
if let Some(cursor) = conn.execute(
    "SELECT year, name FROM Birthdays WHERE ? < year < ?;",
    &params[..])?
{
    // Use cursor to process query results.
}

§Safety

Instances of this type are passed by value, so this type can be implemented by both constant and mutable references. Implementers should take care that the values bound by bind_parameters_to to the statement live at least for the Duration of self. The most straight forward way of achieving this is of course, to bind members.

Required Methods§

Source

fn parameter_set_size(&self) -> usize

Number of values per parameter in the collection. This can be different from the maximum batch size a buffer may be able to hold. Returning 0 will cause the the query not to be executed.

Source

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

§Safety

On execution a statement may want to read/write to the bound paramaters. It is the callers responsibility that by then the buffers are either unbound from the statement or still valild.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ParameterCollectionRef for ()

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement> ParameterCollectionRef for (A,)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement> ParameterCollectionRef for (A, B)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement> ParameterCollectionRef for (A, B, C)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement, T: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement, T: ParameterTupleElement, U: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement, T: ParameterTupleElement, U: ParameterTupleElement, V: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement, T: ParameterTupleElement, U: ParameterTupleElement, V: ParameterTupleElement, W: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement, T: ParameterTupleElement, U: ParameterTupleElement, V: ParameterTupleElement, W: ParameterTupleElement, X: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement, T: ParameterTupleElement, U: ParameterTupleElement, V: ParameterTupleElement, W: ParameterTupleElement, X: ParameterTupleElement, Y: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<A: ParameterTupleElement, B: ParameterTupleElement, C: ParameterTupleElement, D: ParameterTupleElement, E: ParameterTupleElement, F: ParameterTupleElement, G: ParameterTupleElement, H: ParameterTupleElement, I: ParameterTupleElement, J: ParameterTupleElement, K: ParameterTupleElement, L: ParameterTupleElement, M: ParameterTupleElement, N: ParameterTupleElement, O: ParameterTupleElement, P: ParameterTupleElement, Q: ParameterTupleElement, R: ParameterTupleElement, S: ParameterTupleElement, T: ParameterTupleElement, U: ParameterTupleElement, V: ParameterTupleElement, W: ParameterTupleElement, X: ParameterTupleElement, Y: ParameterTupleElement, Z: ParameterTupleElement> ParameterCollectionRef for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<T> ParameterCollectionRef for &T
where T: InputParameterCollection + ?Sized,

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Source§

impl<T> ParameterCollectionRef for &mut T

Source§

fn parameter_set_size(&self) -> usize

Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Implementors§