ad_dbclick_check_dml (public, deprecated)

 ad_dbclick_check_dml [ -bind bind ] statement_name table_name \
    id_column_name generated_id return_url insert_dml

Defined in packages/acs-tcl/tcl/deprecated-procs.tcl

Deprecated. Invoking this procedure generates a warning.

This proc is used for pages using double click protection. table_name is table_name for which we are checking whether the double click occurred. id_column_name is the name of the id table column. generated_id is the generated id, which is supposed to have been generated on the previous page. return_url is url to which this procedure will return redirect in the case of successful insertion in the database. insert_sql is the sql insert statement. if data is ok this procedure will insert data into the database in a double click safe manner and will returnredirect to the page specified by return_url. if database insert fails, this procedure will return a sensible error message to the user.

Switches:
-bind (optional)
Parameters:
statement_name (required)
table_name (required)
id_column_name (required)
generated_id (required)
return_url (required)
insert_dml (required)
See Also:
  • xotcl-request-monitor provides a double-click protection feature that does not rely on the database and is transparent to the developer.

Testcases:
No testcase defined.
Source code:
ad_log_deprecated proc ad_dbclick_check_dml
    if { [catch {
        if { $bind ne "" } {
            db_dml $statement_name $insert_dml -bind $bind
        } else {
            db_dml $statement_name $insert_dml
        }
    } errmsg] } {
        # Oracle choked on the insert

        # detect double click
        if {
            [db_0or1row double_click_check "

        select 1 as one
        from $table_name
        where $id_column_name = :generated_id

        " -bind [ad_tcl_vars_to_ns_set generated_id]]
        } {
            ad_returnredirect $return_url
            return
        }

        ns_log Error "[info script] choked. Oracle returned error:  $errmsg"

        ad_return_error "Error in insert" "
    We were unable to do your insert in the database.
    Here is the error that was returned:
    <p>
    <blockquote>
    <pre>
    $errmsg
    </pre>
    </blockquote>
        </p>"
        return
    }

    ad_returnredirect $return_url
    # should this be ad_script_abort?  Should check how its being used.
    return
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
<fullquery name="ad_dbclick_check_dml.double_click_check">
    <querytext>
      
		
		select 1 as one
		from $table_name
		where $id_column_name = :generated_id
		
	    
      </querytext>
</fullquery>
packages/acs-tcl/tcl/deprecated-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: