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>
impl<'s> CursorRow<'s>
Sourcepub fn get_data(
&mut self,
col_or_param_num: u16,
target: &mut (impl CElement + CDataMut),
) -> Result<(), Error>
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
.
Sourcepub fn get_text(
&mut self,
col_or_param_num: u16,
buf: &mut Vec<u8>,
) -> Result<bool, Error>
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.
Sourcepub fn get_wide_text(
&mut self,
col_or_param_num: u16,
buf: &mut Vec<u16>,
) -> Result<bool, Error>
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.
Sourcepub fn get_binary(
&mut self,
col_or_param_num: u16,
buf: &mut Vec<u8>,
) -> Result<bool, Error>
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.