Struct odbc_safe::Statement
[−]
[src]
pub struct Statement<'con, 'param, 'col, C = NoCursor, A = Unprepared> { /* fields omitted */ }
A Statement
is most easily thought of as an SQL statement, such as
SELECT * FROM Employee
.
- The statement's state
- The current statement-level diagnostics
- The addresses of the application variables bound to the statement's parameters and result set columns
- The current settings of each statement attribute
Specific to the rust wrapper of an ODBC Statement is, that we do keep track
of the lifetimes of
the parent Connection
, parameters as well as columns
bound to the
Statement
. Since it is
possible to unbind the parameters and columns we have to keep track of
their lifetimes
seperatly.
com/sql/odbc/reference/develop-app/statement-handles
Methods
impl<'con, 'param, 'col, S, A> Statement<'con, 'param, 'col, S, A>
[src]
fn as_raw(&self) -> SQLHSTMT
Provides access to the raw ODBC Statement Handle
fn bind_input_parameter<'p, T: ?Sized>(
self,
parameter_number: SQLUSMALLINT,
parameter_type: DataType,
value: Option<&'p T>
) -> Return<Statement<'con, 'p, 'col, S, A>, Self> where
T: CDataType,
'param: 'p,
self,
parameter_number: SQLUSMALLINT,
parameter_type: DataType,
value: Option<&'p T>
) -> Return<Statement<'con, 'p, 'col, S, A>, Self> where
T: CDataType,
'param: 'p,
Binds a parameter to a parameter marker in an SQL Statement
Result
This method will destroy the statement and create a new one which may not outlive the bound
parameter. This is to ensure that the statement will not derefernce an invalid pointer
during execution. Use reset_parameters
to reset the bound parameters and increase the
'param
lifetime back to 'static
.
Arguments
parameter_number
- Index of the marker to bind to the parameter. Starting at1
parameter_type
- SQL Type of the parametervalue
- Reference to bind to the marker
fn bind_col<'col_new, T: ?Sized>(
self,
column_number: SQLUSMALLINT,
value: &'col_new mut T,
indicator: &'col_new mut SQLLEN
) -> Return<Statement<'con, 'param, 'col_new, S, A>, Self> where
T: CDataType,
'col: 'col_new,
self,
column_number: SQLUSMALLINT,
value: &'col_new mut T,
indicator: &'col_new mut SQLLEN
) -> Return<Statement<'con, 'param, 'col_new, S, A>, Self> where
T: CDataType,
'col: 'col_new,
Binds a buffer and an indicator to a column.
See SQLBindCol:
fn reset_parameters(self) -> Statement<'con, 'static, 'col, S, A>
Unbinds the parameters from the parameter markers
fn reset_columns(self) -> Statement<'con, 'param, 'static, S, A>
Unbinds column buffers from result set.
impl<'con, 'param, 'col, C, A> Statement<'con, 'param, 'col, C, A> where
C: CursorState,
[src]
C: CursorState,
fn num_result_cols(&self) -> Return<SQLSMALLINT>
Returns the number of columns of the result set
See SQLNumResultCols
com/sql/odbc/reference/syntax/sqlnumresultcols-function
fn fetch(
self
) -> ReturnOption<Statement<'con, 'param, 'col, Positioned, A>, Statement<'con, 'param, 'col, NoCursor, A>>
self
) -> ReturnOption<Statement<'con, 'param, 'col, Positioned, A>, Statement<'con, 'param, 'col, NoCursor, A>>
Advances Cursor to next row
See SQLFetch See Fetching a Row of Data
com/sql/odbc/reference/syntax/sqlfetch-function
com/sql/odbc/reference/develop-app/fetching-a-row-of-data
fn close_cursor(
self
) -> Return<Statement<'con, 'param, 'col, NoCursor>, Statement<'con, 'param, 'col, C, A>>
self
) -> Return<Statement<'con, 'param, 'col, NoCursor>, Statement<'con, 'param, 'col, C, A>>
Closes the cursor. Cursors only need to be closed explicitly if the Statement handle is intended to be reused, but a result set is not consumed.
See SQLCloseCursor See Closing the Cursor
com/sql/odbc/reference/syntax/sqlclosecursor-function
com/sql/odbc/reference/develop-app/closing-the-cursor
impl<'con, 'param, 'col> Statement<'con, 'param, 'col, NoCursor, Unprepared>
[src]
fn with_parent(parent: &'con Connection) -> Return<Self>
Allocates a new Statement
fn prepare<T: ?Sized>(
self,
statement_text: &T
) -> Return<Statement<'con, 'param, 'col, NoCursor, Prepared>, Statement<'con, 'param, 'col, NoCursor>> where
T: SqlStr,
self,
statement_text: &T
) -> Return<Statement<'con, 'param, 'col, NoCursor, Prepared>, Statement<'con, 'param, 'col, NoCursor>> where
T: SqlStr,
Prepares a Statement
for execution by creating an Access Plan.
See SQLPrepare Function See Prepare and Execute a Statement (ODBC)
com/sql/odbc/reference/syntax/sqlprepare-function
fn exec_direct<T: ?Sized>(
self,
statement_text: &T
) -> ReturnOption<ResultSet<'con, 'param, 'col, Unprepared>, Statement<'con, 'param, 'col, NoCursor>> where
T: SqlStr,
self,
statement_text: &T
) -> ReturnOption<ResultSet<'con, 'param, 'col, Unprepared>, Statement<'con, 'param, 'col, NoCursor>> where
T: SqlStr,
Executes a preparable statement, using the current values of the parametr marker variables.
- See SQLExecDirect
- See Direct Execution
com/sql/odbc/reference/syntax/sqlexecdirect-function
com/sql/odbc/reference/develop-app/direct-execution-odbc
impl<'con, 'param, 'col> Statement<'con, 'param, 'col, NoCursor, Prepared>
[src]
fn execute(self) -> ReturnOption<ResultSet<'con, 'param, 'col, Prepared>, Self>
Executes a prepared statement, using the current values fo the parameter marker variables if any parameter markers exist in the statement.
See SQLExecute Function See Prepared Execution
com/sql/odbc/reference/syntax/sqlexecute-function
com/sql/odbc/reference/develop-app/prepared-execution-odbc
impl<'con, 'param, 'col, A> Statement<'con, 'param, 'col, Positioned, A>
[src]
fn get_data<T: ?Sized>(
&mut self,
col_or_param_num: SQLUSMALLINT,
target: &mut T
) -> ReturnOption<Indicator> where
T: CDataType,
&mut self,
col_or_param_num: SQLUSMALLINT,
target: &mut T
) -> ReturnOption<Indicator> where
T: CDataType,
Retrieves data for a single column or output parameter.
See SQLGetData
com/sql/odbc/reference/syntax/sqlgetdata-function
Trait Implementations
impl<'con, 'param, 'col, C: Debug, A: Debug> Debug for Statement<'con, 'param, 'col, C, A>
[src]
impl<'con, 'param, 'col, C> Diagnostics for Statement<'con, 'param, 'col, C>
[src]
fn diagnostics(
&self,
rec_number: SQLSMALLINT,
message_text: &mut [SQLCHAR]
) -> ReturnOption<DiagResult>
&self,
rec_number: SQLSMALLINT,
message_text: &mut [SQLCHAR]
) -> ReturnOption<DiagResult>
Returns the current values of multiple fields of a diagnostic record that contains error, warning, and status information. Read more