acs::db::SQL method create_db_function_interface (public)

 <instance of acs::db::SQL[i]> create_db_function_interface \
    [ -dbn dbn ] [ -match match ] [ -verbose ]

Defined in packages/acs-tcl/tcl/acs-db-12-procs.tcl

Obtain all function definitions from the DB and turn these into callable Tcl methods like the following examples: ::acs::dc call content_type drop_type -content_type ::xowiki::FormInstance ::acs::dc call content_folder delete -folder_id $root_folder_id -cascade_p 1 In the Oracle-biased terminology such calls are defined in terms of a "package_name" and an "object_name": ::acs::dc call /package_name/ /object_name/ ?/args/?

Switches:
-dbn (optional)
-match (optional, defaults to "*")
-verbose (optional)

Testcases:
No testcase defined.
Source code:
ns_log notice "Creating DB function interface"  "(driver '[::acs::dc cget -driver]', backend '[::acs::dc cget -backend]')"

set db_definitions ""
foreach item [:get_all_package_functions -dbn $dbn] {
    lassign $item package_name object_name sql_info
    #ns_log notice "get_all_package_functions returns ($package_name $object_name)"

    if {[string match "*TRG" [string toupper $object_name]]} {
        # no need to provide interface to trigger functions
        continue
    }

    set package_name [string tolower $package_name]
    set object_name [string tolower $object_name]
    set key ${package_name}.${object_name}
    if {$match ne "*" && ![string match $match $key]} {
        continue
    }

    set nr_args [llength [dict get $sql_info argument_names]]
    if {
        [llength [dict get $sql_info types]] != $nr_args
        || [llength [dict get $sql_info defaulted]] != $nr_args
        || [llength [dict get $sql_info defaults]] != $nr_args
    } {
        ns_log warning "Inconsistent definition skipped: $key"  "argument_names $nr_args"  "types [llength [dict get $sql_info types]]"  "defaulted [llength [dict get $sql_info defaulted]]"  "defaults [llength [dict get $sql_info defaults]]\n"  "names     [dict get $sql_info argument_names]\n"  "types     [dict get $sql_info types]\n"  "defaulted [dict get $sql_info defaulted]\n"  "defaults  [dict get $sql_info defaults]"
        continue
    }

    ns_log notice "generate stub for '$key'"
    if {![dict exists $db_definitions $key]} {
        dict set db_definitions $key package_name $package_name
        dict set db_definitions $key object_name $object_name
        dict set db_definitions $key sql_info $sql_info
    } else {
        #
        # We have multiple definitions. Take the definition
        # with the longest argument list.
        #
        set old_sql_info [dict get $db_definitions $key sql_info]
        if {[llength [dict get $old_sql_info argument_names] <
             [llength dict get $sql_info argument_names]]} {
            dict set db_definitions $key sql_info $sql_info
        }
    }
}
foreach {key v} $db_definitions {
    dict with v {
        :dbfunction_to_tcl -verbose=$verbose  $package_name $object_name $sql_info
    }
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: