Thanks! This looks like what we need. Most helpful!!
"We can not become what we need to be
                          by remaining what we are!"
Jason Thornton
SBC DSL
Web Application Development Team
817 212-8491

 -----Original Message-----
From:   S. Isaac Dealey [mailto:info@;turnkey.to] 
Sent:   Wednesday, November 06, 2002 4:49 PM
To:     [EMAIL PROTECTED]
Subject:        Re: locking queries

Hi Jason,

> We are experiencing problems with users refreshing a page
> in the middle of
> processing and adding multiple entries into SQL. Can this
> be fixed through a
> <CFLOCK> tag around the query? Or does that just work to
> keep OTHER users
> from using the data.

Typically a cflock or cftransaction isn't going to really help you in this
case since those are just used for single-threading access and in this case
it's not an issue of multiple threads per se. What you need to do is check
against the db to see if the insert has already been performed in some way
-- there are a number of ways to do this: my preference when I can get away
with it is something like this:

<cfquery >
        INSERT INTO myxreftable ( foreignkey1, foreignkey1 ) VALUES
        SELECT #form.table1value#, table2.primarykey
        WHERE table2.primarykey IN ( #form.table2value# )
        AND NOT EXISTS ( SELECT * FROM myxreftable
                WHERE foreignkey1 = #form.table1value#
                AND foreignkey2 = table2.primarykey )
</cfquery>

OR

<cfquery>
        IF NOT EXISTS (SELECT * FROM mytable WHERE primarykey =
#form.myprimarykey#)
        INSERT INTO mytable ( mycolumnlist ) VALUES ( #myvalues# )
</cfquery>

There are other ways to control this with CF, although the further away from
the db this process is, the tougher it is to control.

Here's another option -- not sure if you'll like this one, but here goes:

<script language="javascript">
        location.replace("new url here");
</script><cfflush>

<cfquery>
        perform all the form action stuff here
</cfquery>

What this will do is cause the page to load up into the browser before the
cf script has finished processing, and the location.replace() functions like
the <cflocation> tag, replacing the current location in the browser's
history stack, so the user is sent on to the next page without the need to
wait for the action page to parse, insert into the db, etc... The issue
you'll run into here is needing a way to trap errors which occur after the
cfflush tag because users will never see them.

> I am not skilled in these slick city monkey ways,

Thank you for calling me a "slick city monkey", I'm flattered... I think...
;P


Isaac
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046


-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

Reply via email to