Struct odbc_api::parameter::WithDataType[][src]

pub struct WithDataType<T> {
    pub value: T,
    pub data_type: DataType,
}
Expand description

Annotates an instance of an inner type with an SQL Data type in order to indicate how it should be bound as a parameter to an SQL Statement.

Example

use odbc_api::{Environment, parameter::WithDataType, DataType};

let env = Environment::new()?;

let mut conn = env.connect("YourDatabase", "SA", "<YourStrong@Passw0rd>")?;
// Bind year as VARCHAR(4) rather than integer.
let year = WithDataType{
   value: 1980,
   data_type: DataType::Varchar {length: 4}
};
if let Some(cursor) = conn.execute("SELECT year, name FROM Birthdays WHERE year > ?;", &year)? {
    // Use cursor to process query results.
}

Fields

value: T

Value to wrap with a Data Type. Should implement crate::handles::CData, to be useful.

data_type: DataType

The SQL type this value is supposed to map onto. What exactly happens with this information is up to the ODBC driver in use.

Trait Implementations

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. Read more

Indicates the length of variable sized types. May be zero for fixed sized types. Used to determine the size or existence of input parameters. Read more

Pointer to a value corresponding to the one described by cdata_type.

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. Read more

The SQL data as which the parameter is bound to ODBC.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.