::xo::db::DB-oracle ::xo::db::DB-oracle generate_psql get_all_package_functions get_function_args sets ::xo::db::DB ::xo::db::DB 0or1row 1row dml exec_0or1row foreach get_value list list_of_lists multirow prepare profile psql_statement_suffix row_lock transaction ::xo::db::DB-oracle->::xo::db::DB ::xo::db::oracle ::xo::db::oracle ::xo::db::DB-oracle->::xo::db::oracle ::xo::db::DB-postgresql ::xo::db::DB-postgresql 0or1row 1row dml foreach generate_psql get_value insert-view-operation list list_of_lists multirow prepare row_lock sets ::xo::db::DB-postgresql->::xo::db::DB ::xo::db::postgresql ::xo::db::postgresql ::xo::db::DB-postgresql->::xo::db::postgresql ::xo::db::DBI-postgresql ::xo::db::DBI-postgresql ::xo::db::DBI-postgresql->::xo::db::postgresql ::xo::db::DBI ::xo::db::DBI ::xo::db::DBI-postgresql->::xo::db::DBI ::xo::db::Driver ::xo::db::Driver 0or1row 1row dml ds foreach get_sql get_value insert-view-operation list list_of_lists map_default_dbn prepare row_lock sets transaction ::xo::db::DB->::xo::db::Driver ::xotcl::Object ::xotcl::Object ::xo::db::Driver->::xotcl::Object

Class ::xo::db::DB-postgresql

::xo::db::DB-postgresql[i] create ...

Defined in

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xo::db::DB[i], ::xo::db::postgresql[i]

Methods (to be applied on instances)

  • 0or1row (scripted, public)

     <instance of xo::db::DB-postgresql[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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