xo::db::postgresql instproc select (public)

 <instance of xo::db::postgresql[i]> select -vars vars  -from from  \
    [ -where where ] [ -groupby groupby ] [ -limit limit ] \
    [ -offset offset ] [ -start start ] [ -orderby orderby ] \
    [ -map_function_names map_function_names ]

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

Build a PostgreSQL SELECT statement from SQL fragments.

Switches:
-vars (required)
Expressions to select.
-from (required)
FROM clause contents.
-where (optional)
Optional WHERE condition.
-groupby (optional)
Optional grouping expressions.
-limit (optional)
Optional row limit.
-offset (optional)
Optional row offset.
-start (optional)
Compatibility option unused by PostgreSQL.
-orderby (optional)
Optional ordering expressions.
-map_function_names (optional, defaults to "false")
Compatibility option unused by PostgreSQL.

Testcases:
xotcl_core_tutorial_2
Source code:
set where_clause  [expr {$where   ne "" ? "WHERE $where" : ""}]
set offset_clause [expr {$offset  ne "" ? "OFFSET $offset" : ""}]
set limit_clause  [expr {$limit   ne "" ? "LIMIT $limit" : ""}]
set order_clause  [expr {$orderby ne "" ? "ORDER BY $orderby" : ""}]
set group_clause  [expr {$groupby ne "" ? "GROUP BY $groupby" : ""}]
return "SELECT $vars FROM $from $where_clause $group_clause $order_clause $limit_clause $offset_clause"
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: