- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xo::db::DB-postgresql
::xo::db::DB-postgresqlcreate ...
Defined in
Class Relations
Methods (to be applied on instances)
0or1row (scripted, public)
<instance of xo::db::DB-postgresql> 0or1row [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql
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
1row (scripted, public)
<instance of xo::db::DB-postgresql> 1row [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql
Run a query that must return exactly one row and set its columns as variables in the caller. Raise an error 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.
- Returns:
- 1 on success.
- Testcases:
- xotcl_core_tutorial_3, test_xo_db_object, test_cr_items, test_prepared_statements
dml (scripted, public)
<instance of xo::db::DB-postgresql> dml [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql
Execute a data modification statement.
- 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:
- The number of affected rows.
- Testcases:
- xotcl_core_tutorial_2, xotcl_core_tutorial_4, test_cr_items, xowiki_test_cases, slot_interactions
foreach (scripted, public)
<instance of xo::db::DB-postgresql> foreach [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql body
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
generate_psql (scripted, public)
<instance of xo::db::DB-postgresql> generate_psql package_name \ object_name
Generate argument metadata and a Tcl wrapper body for calling a PostgreSQL function through the database API.
- Parameters:
- package_name (required)
- SQL package name.
- object_name (required)
- Function name within the package.
- Returns:
- The argument metadata dictionary with a body entry.
- Testcases:
- xotcl_core_tutorial_2
get_value (scripted, public)
<instance of xo::db::DB-postgresql> get_value [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql [ default ]
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
insert-view-operation (scripted, public)
<instance of xo::db::DB-postgresql> insert-view-operation
Return the database operation used to insert through a PostgreSQL view.
- Returns:
- 0or1row.
- Testcases:
- xotcl_core_tutorial_4, test_cr_items
list (scripted, public)
<instance of xo::db::DB-postgresql> list [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql
Return the first column of each query result row as a list.
- 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.
- Testcases:
- xotcl_core_tutorial_2, xowiki_test_cases
list_of_lists (scripted, public)
<instance of xo::db::DB-postgresql> list_of_lists [ -dbn dbn ] \ [ -bind bind ] [ -with_headers with_headers ] [ -prepare prepare ] \ qn sql
Return each query result row as a list of column values.
- Switches:
- -dbn (optional)
- Database name, or empty for the default.
- -bind (optional)
- Query bind values.
- -with_headers (optional, defaults to
"false")- Include a first list containing the column names.
- -prepare (optional)
- Optional prepared-statement argument types.
- Parameters:
- qn (required)
- Query name.
- sql (required)
- SQL statement.
- Testcases:
- xotcl_core_tutorial_2, xotcl_core_tutorial_3
multirow (scripted, public)
<instance of xo::db::DB-postgresql> multirow [ -dbn dbn ] \ [ -bind bind ] [ -local local ] [ -upvar_level upvar_level ] \ [ -extend extend ] [ -prepare prepare ] var_name qn sql [ body ]
Append query results to a template multirow, creating it if needed.
- Switches:
- -dbn (optional)
- Database name, or empty for the default.
- -bind (optional)
- Bind values for the query.
- -local (optional, defaults to
"false")- Keep the multirow local to the selected caller frame.
- -upvar_level (optional, defaults to
"1")- Caller level at which to store the multirow.
- -extend (optional)
- Additional column names to populate in the row body.
- -prepare (optional)
- Optional argument types for a prepared statement.
- Parameters:
- var_name (required)
- Template multirow name.
- qn (required)
- Query name.
- sql (required)
- SQL statement.
- body (optional)
- Optional Tcl script to run for each row.
- Testcases:
- test_prepared_statements, test_multirow, test_db_out_of_pools
prepare (scripted)
row_lock (scripted, public)
<instance of xo::db::DB-postgresql> row_lock [ -dbn dbn ] \ [ -bind bind ] [ -for for ] [ -prepare prepare ] qn sql
Append a locking clause to a query and return the first column of each row.
- Switches:
- -dbn (optional)
- Database name, or empty for the default.
- -bind (optional)
- Query bind values.
- -for (optional, defaults to
"UPDATE")- Locking clause after FOR, defaulting to UPDATE.
- -prepare (optional)
- Optional prepared-statement argument types.
- Parameters:
- qn (required)
- Query name.
- sql (required)
- SQL statement.
- Testcases:
- xotcl_core_tutorial_4, test_cr_items
sets (scripted, public)
<instance of xo::db::DB-postgresql> sets [ -dbn dbn ] \ [ -bind bind ] [ -prepare prepare ] qn sql
Return a list of ns_set handles, one per query result row.
- 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.
- Testcases:
- xotcl_core_tutorial_2
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
![[i]](/resources/acs-subsite/ZoomIn16.gif)