xo::db::DB-postgresql instproc foreach (public)
<instance of xo::db::DB-postgresql> foreach [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql body
Defined in /var/www/openacs/packages/xotcl-core/tcl/05-db-procs.tcl
Run a query and execute the body in the caller for each row, with the column values available as local variables.
- 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.
- body (required)
- Tcl script to run for each row.
- Testcases:
- test_prepared_statements, test_db_out_of_pools
![[i]](/resources/acs-subsite/ZoomIn16.gif)