[][src]Struct sibyl::Row

pub struct Row<'s> { /* fields omitted */ }

A row in the returned result set

Methods

impl<'r, 's: 'r> Row<'s>[src]

pub fn is_null(&self, pos: usize) -> bool[src]

Returns true if the value in the specified column is NULL.

Example

let stmt = conn.prepare("
    SELECT MAX(commission_pct)
      FROM hr.employees
     WHERE manager_id = :id
")?;
let rows = stmt.query(&[ &120 ])?;
let cur_row = rows.next()?;

assert!(cur_row.is_some());

let row = cur_row.unwrap();
let commission_exists = !row.is_null(0);

assert!(!commission_exists);

Note

This method considers the out of bounds "columns" to be NULL.

pub fn get<T: FromSql<'r>>(&'r self, pos: usize) -> Result<Option<T>>[src]

Returns Option-al value of the specified column in the current row. The returned value is None when the SQL value is NULL

Example

let stmt = conn.prepare("
    SELECT manager_id
      FROM hr.employees
     WHERE employee_id = :id
")?;
let rows = stmt.query(&[ &107 ])?;
let cur_row = rows.next()?;

assert!(cur_row.is_some());

let row = cur_row.unwrap();
let manager_id: u32 = row.get(0)?.unwrap_or_default();

assert_eq!(103, manager_id);

pub fn get_rowid(&self) -> Result<RowID>[src]

Returns the implicitily returned RowID of the current row in the SELECT...FOR UPDATE results. The returned RowID can be used in a later UPDATE or DELETE statement.

Notes

This method is only valid for the SELECT...FOR UPDATE results as only those return ROWIDs implicitly. For all others the returned RowID will be empty (one might think about it as NULL).

Example

let stmt = conn.prepare("
    SELECT manager_id
      FROM hr.employees
     WHERE employee_id = :id
       FOR UPDATE
")?;
let rows = stmt.query(&[ &107 ])?;
let cur_row = rows.next()?;

assert!(cur_row.is_some());

let row = cur_row.unwrap();
let manager_id: u32 = row.get(0)?.unwrap_or_default();

assert_eq!(103, manager_id);

let rowid = row.get_rowid()?;

let stmt = conn.prepare("
    UPDATE hr.employees
       SET manager_id = :mid
     WHERE rowid = :rid
")?;
let num_updated = stmt.execute(&[
    &( ":mid", 102 ),
    &( ":rid", &rowid )
])?;
assert_eq!(1, num_updated);

Auto Trait Implementations

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

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

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]