|
db_foreach Execute a block of code for each result row from a SQL query
package require nstcl-database ?1.0?
package require nstcl ?1.0?
::nstcl::db_foreach statement_name SQL code ?if_no_rows if_no_rows_code ?
db_foreach sends the SQL query to the database and executes code once for each of the result row(s) returned from the database.Each column selected by SQL sets a variable by that name that can be used in the context of code.
Optionally, for the case where SQL returns no rows, an if_no_rows_code code block can be specified which will be evaluated once. Naturally no variables will be set, since no row was returned by the database.
The documentation for the database_api for information on statement_name and which database pool is used to evaluate SQL when multiple pools are defined.
database, nstcl