db_qd_replace_sql (public)

 db_qd_replace_sql [ -ulevel ulevel ] [ -subst subst ] statement_name \
    sql

Defined in packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl

Switches:
-ulevel (optional)
-subst (optional, defaults to "all")
Parameters:
statement_name (required)
sql (required)
Returns:
sql for statement_name (defaulting to sql if not found)

Partial Call Graph (max 5 caller/called nodes):
%3 test_db__db_foreach db__db_foreach (test acs-tcl) db_qd_replace_sql db_qd_replace_sql test_db__db_foreach->db_qd_replace_sql test_db__transaction db__transaction (test acs-tcl) test_db__transaction->db_qd_replace_sql test_db__transaction_bug_3440 db__transaction_bug_3440 (test acs-tcl) test_db__transaction_bug_3440->db_qd_replace_sql test_db_bind_var_substitution db_bind_var_substitution (test acs-tcl) test_db_bind_var_substitution->db_qd_replace_sql db_fullquery_get_querytext db_fullquery_get_querytext (public) db_qd_replace_sql->db_fullquery_get_querytext db_qd_fetch db_qd_fetch (public) db_qd_replace_sql->db_qd_fetch db_blob_get db_blob_get (public) db_blob_get->db_qd_replace_sql db_exec db_exec (public) db_exec->db_qd_replace_sql db_exec_lob_oracle db_exec_lob_oracle (private) db_exec_lob_oracle->db_qd_replace_sql db_exec_lob_postgresql db_exec_lob_postgresql (private) db_exec_lob_postgresql->db_qd_replace_sql db_exec_plpgsql db_exec_plpgsql (private) db_exec_plpgsql->db_qd_replace_sql

Testcases:
db__db_foreach, db_bind_var_substitution, db__transaction, db__transaction_bug_3440
Source code:
    set fullquery [db_qd_fetch $statement_name]

    if {$fullquery ne ""} {
        set sql [db_fullquery_get_querytext $fullquery]

        if {[info exists ulevel]} {
            if {$subst ne "none"} {
                if {$subst eq "all"} {
                    set flags -nobackslashes
                } elseif {$subst eq "vars"} {
                    set flags "-nobackslashes -nocommands"
                } elseif {$subst eq "commands"} {
                    set flags "-nobackslashes -novars"
                } else {
                    ns_log warning "invalid value passed to '-subst': $subst. possible: all, none, vars, commands"
                    set flags -nobackslashes
                }
                set sql [uplevel $ulevel [list subst {*}$flags $sql]]
            }
        }
    } else {
        #db_qd_log Debug "NO FULLQUERY FOR $statement_name --> using default SQL"
        if { $sql eq "" } {
            # The default SQL is empty, that implies a bug somewhere in the code.
            error "No fullquery for $statement_name and default SQL empty - query for statement missing"
        }
    }

    return $sql
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: