[−][src]Struct odbc_safe::Statement
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.
Methods
impl<'con, 'param, 'col, S, A> Statement<'con, 'param, 'col, S, A>
[src]
pub fn as_raw(&self) -> SQLHSTMT
[src]
Provides access to the raw ODBC Statement Handle
pub fn bind_input_parameter<'p, T: ?Sized>(
self,
parameter_number: SQLUSMALLINT,
parameter_type: DataType,
value: &'p T,
indicator: Option<&'p SQLLEN>
) -> Return<Statement<'con, 'p, 'col, S, A>, Self> where
T: CDataType,
'param: 'p,
[src]
self,
parameter_number: SQLUSMALLINT,
parameter_type: DataType,
value: &'p T,
indicator: Option<&'p SQLLEN>
) -> 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
See [SQLBindParameter Function][1] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlbindparameter-function#columnsize-argument
pub fn bind_col<'col_new, T: ?Sized>(
self,
column_number: SQLUSMALLINT,
value: &'col_new mut T,
indicator: Option<&'col_new mut SQLLEN>
) -> Return<Statement<'con, 'param, 'col_new, S, A>, Self> where
T: CDataType,
'col: 'col_new,
[src]
self,
column_number: SQLUSMALLINT,
value: &'col_new mut T,
indicator: Option<&'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][1]: [1]: [https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlbindcol-function]
pub fn reset_parameters(self) -> Statement<'con, 'static, 'col, S, A>
[src]
Unbinds the parameters from the parameter markers
pub fn reset_columns(self) -> Statement<'con, 'param, 'static, S, A>
[src]
Unbinds column buffers from result set.
impl<'con, 'param, 'col, C, A> Statement<'con, 'param, 'col, C, A> where
C: CursorState,
[src]
C: CursorState,
pub fn num_result_cols(&self) -> Return<SQLSMALLINT>
[src]
Returns the number of columns of the result set
See [SQLNumResultCols][1] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlnumresultcols-function
pub fn affected_row_count(&self) -> Return<SQLLEN>
[src]
Returns the number of rows affetced by INSERT, UPDATE, etc
See [SQLRowCount][1] [1]: https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlrowcount-function
pub fn fetch(
self
) -> ReturnOption<Statement<'con, 'param, 'col, Positioned, A>, Statement<'con, 'param, 'col, NoCursor, A>>
[src]
self
) -> ReturnOption<Statement<'con, 'param, 'col, Positioned, A>, Statement<'con, 'param, 'col, NoCursor, A>>
Advances Cursor to next row
See [SQLFetch][1] See [Fetching a Row of Data][2] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlfetch-function [2]: https://docs.microsoft.com/sql/odbc/reference/develop-app/fetching-a-row-of-data
pub fn close_cursor(
self
) -> Return<Statement<'con, 'param, 'col, NoCursor>, Statement<'con, 'param, 'col, C, A>>
[src]
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][1] See [Closing the Cursor][2] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlclosecursor-function [2]: https://docs.microsoft.com/sql/odbc/reference/develop-app/closing-the-cursor
pub fn describe_col<T: ?Sized>(
&mut self,
column_number: SQLUSMALLINT,
column_name: &mut T,
column_name_indicator: &mut SQLSMALLINT,
nullable: &mut Nullable
) -> Return<Option<DataType>> where
T: OutputBuffer,
[src]
&mut self,
column_number: SQLUSMALLINT,
column_name: &mut T,
column_name_indicator: &mut SQLSMALLINT,
nullable: &mut Nullable
) -> Return<Option<DataType>> where
T: OutputBuffer,
Return information about result set column
See [SQLDescribeCol Function][1] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqldescribecol-function
impl<'con, 'param, 'col> Statement<'con, 'param, 'col, NoCursor, Unprepared>
[src]
pub fn with_parent<AC: AutocommitMode>(
parent: &'con Connection<AC>
) -> Return<Self>
[src]
parent: &'con Connection<AC>
) -> Return<Self>
Allocates a new Statement
pub fn prepare<T: ?Sized>(
self,
statement_text: &T
) -> Return<Statement<'con, 'param, 'col, NoCursor, Prepared>, Statement<'con, 'param, 'col, NoCursor>> where
T: SqlStr,
[src]
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][1] See [Prepare and Execute a Statement (ODBC)][2] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlprepare-function [2]: https://docs.microsoft.com/sql/relational-databases/native-client-odbc-how-to/execute-queries/prepare-and-execute-a-statement-odbc
pub fn exec_direct<T: ?Sized>(
self,
statement_text: &T
) -> ReturnOption<ResultSet<'con, 'param, 'col, Unprepared>, Statement<'con, 'param, 'col, NoCursor>> where
T: SqlStr,
[src]
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][1]
- See [Direct Execution][2] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlexecdirect-function [2]: https://docs.microsoft.com/sql/odbc/reference/develop-app/direct-execution-odbc
impl<'con, 'param, 'col> Statement<'con, 'param, 'col, NoCursor, Prepared>
[src]
pub fn describe_col<T: ?Sized>(
&mut self,
column_number: SQLUSMALLINT,
column_name: &mut T,
column_name_indicator: &mut SQLSMALLINT,
nullable: &mut Nullable
) -> Return<Option<DataType>> where
T: OutputBuffer,
[src]
&mut self,
column_number: SQLUSMALLINT,
column_name: &mut T,
column_name_indicator: &mut SQLSMALLINT,
nullable: &mut Nullable
) -> Return<Option<DataType>> where
T: OutputBuffer,
Return information about result set column
See [SQLDescribeCol Function][1] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqldescribecol-function
pub fn execute(
self
) -> ReturnOption<ResultSet<'con, 'param, 'col, Prepared>, Self>
[src]
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][1] See [Prepared Execution][2] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlexecute-function [2]: https://docs.microsoft.com/sql/odbc/reference/develop-app/prepared-execution-odbc
impl<'con, 'param, 'col, A> Statement<'con, 'param, 'col, Positioned, A>
[src]
pub fn get_data<T: ?Sized>(
&mut self,
col_or_param_num: SQLUSMALLINT,
target: &mut T
) -> ReturnOption<Indicator> where
T: CDataType,
[src]
&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][1] [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlgetdata-function
Trait Implementations
impl<'con, 'param, 'col, C, A> Diagnostics for Statement<'con, 'param, 'col, C, A>
[src]
fn diagnostics(
&self,
rec_number: SQLSMALLINT,
message_text: &mut [SQLCHAR]
) -> ReturnOption<DiagResult>
[src]
&self,
rec_number: SQLSMALLINT,
message_text: &mut [SQLCHAR]
) -> ReturnOption<DiagResult>
impl<'con, 'param, 'col, C: Debug, A: Debug> Debug for Statement<'con, 'param, 'col, C, A>
[src]
Auto Trait Implementations
impl<'con, 'param, 'col, C = NoCursor, A = Unprepared> !Send for Statement<'con, 'param, 'col, C, A>
impl<'con, 'param, 'col, C = NoCursor, A = Unprepared> !Sync for Statement<'con, 'param, 'col, C, A>
impl<'con, 'param, 'col, C, A> Unpin for Statement<'con, 'param, 'col, C, A> where
A: Unpin,
C: Unpin,
A: Unpin,
C: Unpin,
impl<'con, 'param, 'col, C, A> UnwindSafe for Statement<'con, 'param, 'col, C, A> where
A: UnwindSafe,
C: UnwindSafe,
A: UnwindSafe,
C: UnwindSafe,
impl<'con, 'param, 'col, C, A> RefUnwindSafe for Statement<'con, 'param, 'col, C, A> where
A: RefUnwindSafe,
C: RefUnwindSafe,
A: RefUnwindSafe,
C: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,