[−][src]Struct odbc_api::handles::Statement
Wraps a valid (i.e. successfully allocated) ODBC statement handle.
Implementations
impl<'s> Statement<'s>
[src]
pub unsafe fn new(handle: HStmt) -> Self
[src]
Safety
handle
must be a valid (successfully allocated) statement handle.
pub unsafe fn exec_direct(
&mut self,
statement_text: &U16Str
) -> Result<bool, Error>
[src]
&mut self,
statement_text: &U16Str
) -> Result<bool, Error>
Executes a prepareable statement, using the current values of the parameter marker variables if any parameters exist in the statement. SQLExecDirect is the fastest way to submit an SQL statement for one-time execution.
Safety
While self
as always guaranteed to be a valid allocated handle, this function may
dereference bound parameters. It is the callers responsibility to ensure these are still
valid. One strategy is to reset potentially invalid parameters right before the call using
reset_parameters
.
Return
Returns true
if a cursor is created. If false
is returned no cursor has been created (
e.g. the query came back empty). Note that an empty query may also create a cursor with zero
rows. If a cursor is created. close_cursor
should be called after it is no longer used.
pub fn prepare(&mut self, statement_text: &U16Str) -> Result<(), Error>
[src]
Send an SQL statement to the data source for preparation. The application can include one or more parameter markers in the SQL statement. To include a parameter marker, the application embeds a question mark (?) into the SQL string at the appropriate position.
pub fn execute(&mut self) -> Result<(), Error>
[src]
Executes a statement prepared by prepare
. After the application processes or discards the
results from a call to execute
, the application can call SQLExecute again with new
parameter values.
Safety
While self
as always guaranteed to be a valid allocated handle, this function may
dereference bound parameters. It is the callers responsibility to ensure these are still
valid. One strategy is to reset potentially invalid parameters right before the call using
reset_parameters
.
pub fn close_cursor(&mut self) -> Result<(), Error>
[src]
Close an open cursor.
pub fn describe_col(
&self,
column_number: u16,
column_description: &mut ColumnDescription
) -> Result<(), Error>
[src]
&self,
column_number: u16,
column_description: &mut ColumnDescription
) -> Result<(), Error>
Fetch a column description using the column index.
Parameters
column_number
: Column index.0
is the bookmark column. The other column indices start with1
.column_description
: Holds the description of the column after the call. This method does not provide strong exception safety as the value of this argument is undefined in case of an error.
pub fn num_result_cols(&self) -> Result<i16, Error>
[src]
Number of columns in result set.
pub unsafe fn set_row_array_size(&mut self, size: u32) -> Result<(), Error>
[src]
Sets the batch size for bulk cursors, if retrieving many rows at once.
Safety
It is the callers responsibility to ensure that buffers bound using bind_col
can hold the
specified amount of rows.
pub unsafe fn set_num_rows_fetched(
&mut self,
num_rows: &mut ULen
) -> Result<(), Error>
[src]
&mut self,
num_rows: &mut ULen
) -> Result<(), Error>
Bind an integer to hold the number of rows retrieved with fetch in the current row set.
Safety
num_rows
must not be moved and remain valid, as long as it remains bound to the cursor.
pub unsafe fn set_row_bind_type(&mut self, row_size: u32) -> Result<(), Error>
[src]
Sets the binding type to columnar binding for batch cursors.
Any Positive number indicates a row wise binding with that row length. 0
indicates a
columnar binding.
Safety
It is the callers responsibility to ensure that the bound buffers match the memory layout specified by this function.
pub fn fetch(&mut self) -> Result<bool, Error>
[src]
Returns the next rowset in the result set.
It can be called only while a result set exists: I.e., after a call that creates a result
set and before the cursor over that result set is closed. If any columns are bound, it
returns the data in those columns. If the application has specified a pointer to a row
status array or a buffer in which to return the number of rows fetched, fetch
also returns
this information. Calls to fetch
can be mixed with calls to fetch_scroll
.
pub fn unbind_cols(&mut self) -> Result<(), Error>
[src]
Release all column buffers bound by bind_col
. Except bookmark column.
pub unsafe fn bind_col(
&mut self,
column_number: u16,
target_type: CDataType,
target_value: Pointer,
target_length: Len,
indicator: *mut Len
) -> Result<(), Error>
[src]
&mut self,
column_number: u16,
target_type: CDataType,
target_value: Pointer,
target_length: Len,
indicator: *mut Len
) -> Result<(), Error>
Binds application data buffers to columns in the result set.
column_number
:0
is the bookmark column. It is not included in some result sets. All other columns are numbered starting with1
. It is an error to bind a higher-numbered column than there are columns in the result set. This error cannot be detected until the result set has been created, so it is returned byfetch
, notbind_col
.target_type
: The identifier of the C data type of thevalue
buffer. When it is retrieving data from the data source withfetch
, the driver converts the data to this type. When it sends data to the source, the driver converts the data from this type.target_value
: Pointer to the data buffer to bind to the column.target_length
: Length of target value in bytes. (Or for a single element in case of bulk aka. block fetching data).indicator
: Buffer is going to hold length or indicator values.
Safety
It is the callers responsibility to make sure the bound columns live until they are no longer bound.
pub unsafe fn bind_parameter(
&mut self,
parameter_number: u16,
input_output_type: ParamType,
value_type: CDataType,
parameter_type: DataType,
parameter_value_ptr: Pointer,
buffer_length: Len,
str_len_or_ind_ptr: *mut Len
) -> Result<(), Error>
[src]
&mut self,
parameter_number: u16,
input_output_type: ParamType,
value_type: CDataType,
parameter_type: DataType,
parameter_value_ptr: Pointer,
buffer_length: Len,
str_len_or_ind_ptr: *mut Len
) -> Result<(), Error>
Binds a buffer to a parameter marker in an SQL statement.
See https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlbindparameter-function.
Parameters
...
buffer_length
: Used to calculate the position of individual parameters then binding buffers or to truncate binary and character data in case of output. ...
Safety
- It is up to the caller to ensure the lifetimes of the bound parameters.
- Calling this function may influence other statements that share the APD.
pub fn is_unsigned_column(&self, column_number: u16) -> Result<bool, Error>
[src]
true
if a given column in a result set is unsigned or not a numeric type, false
otherwise.
column_number
: Index of the column, starting at 1.
pub fn col_type(&self, column_number: u16) -> Result<SqlDataType, Error>
[src]
Returns a number identifying the SQL type of the column in the result set.
column_number
: Index of the column, starting at 1.
pub fn col_concise_type(&self, column_number: u16) -> Result<SqlDataType, Error>
[src]
The concise data type. For the datetime and interval data types, this field returns the
concise data type; for example, TIME
or INTERVAL_YEAR
.
column_number
: Index of the column, starting at 1.
pub fn col_octet_length(&self, column_number: u16) -> Result<Len, Error>
[src]
Returns the size in bytes of the columns. For variable sized types the maximum size is returned, excluding a terminating zero.
column_number
: Index of the column, starting at 1.
pub fn col_display_size(&self, column_number: u16) -> Result<Len, Error>
[src]
Maximum number of characters required to display data from the column.
column_number
: Index of the column, starting at 1.
pub fn col_precision(&self, column_number: u16) -> Result<Len, Error>
[src]
Precision of the column.
Denotes the applicable precision. For data types SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP, and all the interval data types that represent a time interval, its value is the applicable precision of the fractional seconds component.
pub fn col_scale(&self, column_number: u16) -> Result<Len, Error>
[src]
The applicable scale for a numeric data type. For DECIMAL and NUMERIC data types, this is the defined scale. It is undefined for all other data types.
pub fn col_name(
&self,
column_number: u16,
buf: &mut Vec<u16>
) -> Result<(), Error>
[src]
&self,
column_number: u16,
buf: &mut Vec<u16>
) -> Result<(), Error>
The column alias, if it applies. If the column alias does not apply, the column name is returned. If there is no column name or a column alias, an empty string is returned.
pub fn application_row_descriptor(&self) -> Result<Description<'_>, Error>
[src]
pub fn reset_parameters(&mut self) -> Result<(), Error>
[src]
Sets the SQL_DESC_COUNT field of the APD to 0, releasing all parameter buffers set for the given StatementHandle.
Trait Implementations
impl<'c> AsHandle for Statement<'c>
[src]
fn as_handle(&self) -> Handle
[src]
fn handle_type(&self) -> HandleType
[src]
impl<'s> Drop for Statement<'s>
[src]
Auto Trait Implementations
impl<'s> RefUnwindSafe for Statement<'s>
impl<'s> !Send for Statement<'s>
impl<'s> !Sync for Statement<'s>
impl<'s> Unpin for Statement<'s>
impl<'s> UnwindSafe for Statement<'s>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,