Trait odbc_api::Cursor[][src]

pub trait Cursor {
    type Statement: Statement;
    unsafe fn stmt(&mut self) -> &mut Self::Statement;
fn describe_col(
        &self,
        column_number: u16,
        column_description: &mut ColumnDescription
    ) -> Result<(), Error>;
fn num_result_cols(&self) -> Result<i16, Error>;
fn is_unsigned_column(&self, column_number: u16) -> Result<bool, Error>;
fn bind_buffer<B>(
        self,
        row_set_buffer: B
    ) -> Result<RowSetCursor<Self, B>, Error>
    where
        Self: Sized,
        B: RowSetBuffer
;
fn col_data_type(&self, column_number: u16) -> Result<DataType, Error>;
fn col_octet_length(&self, column_number: u16) -> Result<isize, Error>;
fn col_display_size(&self, column_number: u16) -> Result<isize, Error>;
fn col_precision(&self, column_number: u16) -> Result<isize, Error>;
fn col_scale(&self, column_number: u16) -> Result<isize, Error>;
fn col_name(
        &self,
        column_number: u16,
        buf: &mut Vec<u16>
    ) -> Result<(), Error>; fn next_row(
        &mut self
    ) -> Result<Option<CursorRow<'_, Self::Statement>>, Error> { ... }
fn column_names(&self) -> Result<ColumnNamesIt<'_, Self>, Error> { ... } }

Cursors are used to process and iterate the result sets returned by executing queries.

Associated Types

type Statement: Statement[src]

Statement type of the cursor. This is always an instantiation of crate::handles::Statement with a generic parameter indicating the lifetime of the associated connection.

So this trait could have had a lifetime parameter instead and provided access to the underlying type. However by using the projection of only the cursor methods of the underlying statement, consumers of this trait no only have to worry about the lifetime of the statement itself (e.g. the prepared query) and not about the lifetime of the connection it belongs to.

Loading content...

Required methods

unsafe fn stmt(&mut self) -> &mut Self::Statement[src]

Provides access to the underlying statement handle.

Safety

Assinging to this statement handle or binding buffers to it may invalidate the invariants of safe wrapper types (i.e. crate::RowSetCursor). Some actions like closing the cursor may just result in ODBC transition errors, others like binding columns may even cause actual invalid memory access if not used with care.

fn describe_col(
    &self,
    column_number: u16,
    column_description: &mut ColumnDescription
) -> Result<(), Error>
[src]

Fetch a column description using the column index.

Parameters

  • column_number: Column index. 0 is the bookmark column. The other column indices start with 1.
  • 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.

fn num_result_cols(&self) -> Result<i16, Error>[src]

Number of columns in result set.

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.

fn bind_buffer<B>(
    self,
    row_set_buffer: B
) -> Result<RowSetCursor<Self, B>, Error> where
    Self: Sized,
    B: RowSetBuffer
[src]

Binds this cursor to a buffer holding a row set.

fn col_data_type(&self, column_number: u16) -> Result<DataType, Error>[src]

Data type of the specified column.

column_number: Index of the column, starting at 1.

fn col_octet_length(&self, column_number: u16) -> Result<isize, 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.

fn col_display_size(&self, column_number: u16) -> Result<isize, Error>[src]

Maximum number of characters required to display data from the column.

column_number: Index of the column, starting at 1.

fn col_precision(&self, column_number: u16) -> Result<isize, 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.

fn col_scale(&self, column_number: u16) -> Result<isize, 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.

fn col_name(&self, column_number: u16, buf: &mut Vec<u16>) -> Result<(), Error>[src]

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.

Loading content...

Provided methods

fn next_row(&mut self) -> Result<Option<CursorRow<'_, Self::Statement>>, Error>[src]

Advances the cursor to the next row in the result set.

While this method is very convinient due to the fact that the application does not have to declare and bind specific buffers it is also in many situations extremly slow. Concrete performance depends on the ODBC driver in question, but it is likely it performs a roundtrip to the datasource for each individual row. It is also likely an extra conversion is performed then requesting individual fields, since the C buffer type is not known to the driver in advance. Consider binding a buffer to the cursor first using Self::bind_buffer.

fn column_names(&self) -> Result<ColumnNamesIt<'_, Self>, Error>[src]

Use this if you want to iterate over all column names and allocate a String for each one.

This is a wrapper around col_name introduced for convenience.

Loading content...

Implementors

impl<'o, S> Cursor for CursorImpl<'o, S> where
    S: BorrowMut<StatementImpl<'o>>, 
[src]

type Statement = StatementImpl<'o>

Loading content...