postgres/row
src/postgres/row.tur
defn
rows-count
(rows-count [rows :int] :int)
return the number of rows in a result set.
Parameters
| rows | rows handle (ok-val from db-query or stmt-exec-prepared) |
Returns
Row count as :int.
Example
(rows-count rows) ; => 3
Since: PG0
defn
rows-free
(rows-free [rows :int] :void)
release a result set returned by db-query or stmt-exec-prepared.
Parameters
| rows | rows handle to free |
Returns
void
Example
(rows-free rows)
Since: PG0
defn
row-get
(row-get [rows :int i :int colname :cstr] :cstr)
retrieve a column value by name from a specific row.
Parameters
| rows | rows handle | |
| i | 0-based row index | |
| colname | column name as :cstr |
Returns
Column text value as :cstr; "" if column not found or value is NULL.
Example
(row-get rows 0 "name") ; => "Alice"
Since: PG0
defn
row-get-int
(row-get-int [rows :int i :int colname :cstr] :int)
retrieve a column value by name as an integer.
Parameters
| rows | rows handle | |
| i | 0-based row index | |
| colname | column name as :cstr |
Returns
Column value converted from text to :int via atoi; 0 if not found or NULL.
Example
(row-get-int rows 0 "id") ; => 42
Since: PG0
defn
col-count
(col-count [rows :int] :int)
return the number of columns in a result set.
Parameters
| rows | rows handle |
Returns
Column count as :int.
Example
(col-count rows) ; => 2
Since: PG0
defn
col-name
(col-name [rows :int j :int] :cstr)
return the name of a column at 0-based index j.
Parameters
| rows | rows handle | |
| j | 0-based column index |
Returns
Column name as :cstr (valid until rows-free); "" if out of range.
Example
(col-name rows 0) ; => "id"
Since: PG0