odbc_api

Struct CursorRow

Source
pub struct CursorRow<'s> { /* private fields */ }
Expand description

An individual row of an result set. See crate::Cursor::next_row.

Implementations§

Source§

impl<'s> CursorRow<'s>

Source

pub fn get_data( &mut self, col_or_param_num: u16, target: &mut (impl CElement + CDataMut), ) -> Result<(), Error>

Fills a suitable target buffer with a field from the current row of the result set. This method drains the data from the field. It can be called repeatedly to if not all the data fit in the output buffer at once. It should not called repeatedly to fetch the same value twice. Column index starts at 1.

Source

pub fn get_text( &mut self, col_or_param_num: u16, buf: &mut Vec<u8>, ) -> Result<bool, Error>

Retrieves arbitrary large character data from the row and stores it in the buffer. Column index starts at 1. The used encoding is accordig to the ODBC standard determined by your system local. Ultimatly the choice is up to the implementation of your ODBC driver, which often defaults to always UTF-8.

§Example

Retrieve an arbitrary large text file from a database field.

use odbc_api::{Connection, Error, IntoParameter, Cursor};

fn get_large_text(name: &str, conn: &mut Connection<'_>) -> Result<Option<String>, Error> {
    let mut cursor = conn
        .execute("SELECT content FROM LargeFiles WHERE name=?", &name.into_parameter())?
        .expect("Assume select statement creates cursor");
    if let Some(mut row) = cursor.next_row()? {
        let mut buf = Vec::new();
        row.get_text(1, &mut buf)?;
        let ret = String::from_utf8(buf).unwrap();
        Ok(Some(ret))
    } else {
        Ok(None)
    }
}
§Return

true indicates that the value has not been NULL and the value has been placed in buf. false indicates that the value is NULL. The buffer is cleared in that case.

Source

pub fn get_wide_text( &mut self, col_or_param_num: u16, buf: &mut Vec<u16>, ) -> Result<bool, Error>

Retrieves arbitrary large character data from the row and stores it in the buffer. Column index starts at 1. The used encoding is UTF-16.

§Return

true indicates that the value has not been NULL and the value has been placed in buf. false indicates that the value is NULL. The buffer is cleared in that case.

Source

pub fn get_binary( &mut self, col_or_param_num: u16, buf: &mut Vec<u8>, ) -> Result<bool, Error>

Retrieves arbitrary large binary data from the row and stores it in the buffer. Column index starts at 1.

§Return

true indicates that the value has not been NULL and the value has been placed in buf. false indicates that the value is NULL. The buffer is cleared in that case.

Auto Trait Implementations§

§

impl<'s> Freeze for CursorRow<'s>

§

impl<'s> RefUnwindSafe for CursorRow<'s>

§

impl<'s> !Send for CursorRow<'s>

§

impl<'s> !Sync for CursorRow<'s>

§

impl<'s> Unpin for CursorRow<'s>

§

impl<'s> UnwindSafe for CursorRow<'s>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.