xo::db::DB-postgresql instproc 0or1row (public)
<instance of xo::db::DB-postgresql> 0or1row [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql
Defined in /var/www/openacs/packages/xotcl-core/tcl/05-db-procs.tcl
Run a query that returns at most one row. Set caller variables from the columns if a row is present.
- Switches:
- -dbn (optional)
- Database name, or empty for the default.
- -bind (optional)
- Query bind values.
- -prepare (optional)
- Optional prepared-statement argument types.
- Parameters:
- qn (required)
- Query name.
- sql (required)
- SQL statement.
- Returns:
- 1 if a row was found, or 0 otherwise.
- Testcases:
- test_xo_db_object, test_cr_items, xowiki_test_cases
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 ""} { foreach {att val} [ns_set array $answers] { uplevel [list set $att $val] } ns_set free $answers return 1 } return 0XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)