Struct odbc_api::RowSetCursor
source · [−]pub struct RowSetCursor<C: Cursor, B> { /* private fields */ }
Expand description
A row set cursor iterates in blocks over row sets, filling them in buffers, instead of iterating the result set row by row. This is usually much faster.
Implementations
sourceimpl<C, B> RowSetCursor<C, B> where
C: Cursor,
impl<C, B> RowSetCursor<C, B> where
C: Cursor,
sourcepub fn fetch(&mut self) -> Result<Option<&B>, Error>
pub fn fetch(&mut self) -> Result<Option<&B>, Error>
Fills the bound buffer with the next row set.
Return
None
if the result set is empty and all row sets have been extracted. Some
with a
reference to the internal buffer otherwise.
use odbc_api::{buffers::TextRowSet, Cursor};
fn print_all_values(cursor: impl Cursor) {
let batch_size = 100;
let max_string_len = 4000;
let buffer = TextRowSet::for_cursor(batch_size, &cursor, Some(4000)).unwrap();
let mut cursor = cursor.bind_buffer(buffer).unwrap();
// Iterate over batches
while let Some(batch) = cursor.fetch().unwrap() {
// ... print values in batch ...
}
}
sourcepub fn fetch_with_truncation_check(
&mut self,
error_for_truncation: bool
) -> Result<Option<&B>, Error>
pub fn fetch_with_truncation_check(
&mut self,
error_for_truncation: bool
) -> Result<Option<&B>, Error>
Fills the bound buffer with the next row set. Should error_for_truncation
be true
and any
diagnostic indicate truncation of a value an error is returned.
Return
None
if the result set is empty and all row sets have been extracted. Some
with a
reference to the internal buffer otherwise.
/// Call this method to find out wether there are any truncated values in the batch, without inspecting all its rows and columns.
use odbc_api::{buffers::TextRowSet, Cursor};
fn print_all_values(cursor: impl Cursor) {
let batch_size = 100;
let max_string_len = 4000;
let buffer = TextRowSet::for_cursor(batch_size, &cursor, Some(4000)).unwrap();
let mut cursor = cursor.bind_buffer(buffer).unwrap();
// Iterate over batches
while let Some(batch) = cursor.fetch_with_truncation_check(true).unwrap() {
// ... print values in batch ...
}
}
Trait Implementations
Auto Trait Implementations
impl<C, B> RefUnwindSafe for RowSetCursor<C, B> where
B: RefUnwindSafe,
C: RefUnwindSafe,
impl<C, B> Send for RowSetCursor<C, B> where
B: Send,
C: Send,
impl<C, B> Sync for RowSetCursor<C, B> where
B: Sync,
C: Sync,
impl<C, B> Unpin for RowSetCursor<C, B> where
B: Unpin,
C: Unpin,
impl<C, B> UnwindSafe for RowSetCursor<C, B> where
B: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more