xo::db::DB-postgresql instproc get_value (public)

 <instance of xo::db::DB-postgresql[i]> get_value [ -dbn dbn ] \
    [ -bind bind ] [ -prepare prepare ] qn sql [ default ]

Defined in /var/www/openacs/packages/xotcl-core/tcl/05-db-procs.tcl

Return the first column of a single-row query, or the default if there is no row.

Switches:
-dbn (optional)
Database name, or empty for the default.
-bind (optional)
Bind values for the query.
-prepare (optional)
Optional argument types for a prepared statement.
Parameters:
qn (required)
Query name.
sql (required)
SQL statement.
default (optional)
Value to return when the query produces no rows.

Testcases:
xotcl_core_tutorial_1, xotcl_core_tutorial_2, xotcl_core_tutorial_4, test_xo_db_object, test_cr_items, test_prepared_statements, xowiki_test_cases, path_resolve
Source code:
if {$sql eq ""} {set sql [:get_sql $qn]}
set prepOpt [expr {[info exists prepare] ? [list -prepare $prepare] : ""}]
set answers [uplevel [list [self] exec_0or1row -dbn $dbn {*}$prepOpt -bind $bind $sql]]
if {$answers ne ""} {
  set result [ns_set value $answers 0]
  ns_set free $answers
  return $result
}
return $default
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: