ad_dbclick_check_dml

one of the documented procedures in this installation of the ACS
Usage:
ad_dbclick_check_dml   db   table_name   id_column_name   generated_id   return_url   insert_sql
What it does:
this proc is used for pages using double click protection. table_name is table_name for which we are checking whether the double click occured. 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.
Defined in: /web/philip/packages/acs-core/utilities-procs.tcl

Source code:


    if [catch { 
	ns_db dml $db $insert_sql
    } errmsg] {
	# Oracle choked on the insert
	
	# detect double click
	set selection [ns_db 0or1row $db "
	select 1
	from $table_name
	where $id_column_name='[DoubleApos $generated_id]'"]
	
	if { ![empty_string_p $selection] } {
	    # it's a double click, so just redirect the user to the index page
	    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>"
	return
    }

    ad_returnredirect $return_url
    return


philg@mit.edu