I had intuitively figured out how bad my solution was. I could justify
it only because this query is taking place on a data maintenance page
that would only every be used by one staff member - never by the general
public. 

However, thanks to Patrick and others, I won't need it.

By the way, my first CF web site, helped in no small part by you clever
listers, is just about ready.  Still a bit of data to go into some
pages, and a bit of work on the design and css, but most of the master
detail sets are now finished and data is doing what it's supposed to on
the browser (for the most part).

Constructive criticism is welcome. http://63.135.112.196

Thanks,

Tom

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of TRACEY,
Darren
Sent: Thursday, 29 July 2004 3:08 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Identifying the record you have just created

I'm sure (and hope) you know this, but do you realise just how bodgy
your bodgy workaround really is?

If two people do this action at or near the same time, it is possible
that they will both insert their records, with the flag set to true,
before either one gets around to looking for true flags.
You then have the 'lucky winner' being handed 2 records, when it only
expects 1, and then the possibility that it will delete both these
values before the second user's thread gets around to looking for its
true flag, thus giving it no records.
Another alternative is that both threads could be given both values.
Things will only get messy after either of these.

These are called 'race conditions' and should be avoided at all costs.

The solution you're asking for (the answer will depend on your database)
will fix this situation.

Another way to avoid this would be to not add a value of 'true' to the
new record, but give it a unique value (possibly a UUID), pass that
value through the cflocation, then do a select that looks for that
specific value.
The value could be cleared once its work has been done if you wish.

Regards 

Darren Tracey
Systems Analyst
Web Applications, Web and Integration Services
p: + 61 7 3232 4091 (x64091)
f: + 61 7 3232 4744
e: [EMAIL PROTECTED]
l: Lvl 9, 388 Queen St Brisbane QLD 4000
m: Suncorp IPC IT040, GPO Box 1453, Brisbane QLD 4000

> -----Original Message-----
> From: Tom MacKean [SMTP:[EMAIL PROTECTED]
> Sent: Thursday, 29 July 2004 14:52
> To:   CFAussie Mailing List
> Subject:      [cfaussie] Identifying the record you have just created
> 
> Hi all,
> 
> I have a form that passes data to an INSERT INTO action page. That 
> page creates a new record with an incremented ID number (primary key).

> Is there a way to find out what that ID number is so that it can be 
> used for another query on the same page?
> 
> I have a bodgy workaround whereby I set a value in a special field to 
> true, then cflocation to another page that searches for that true 
> value and picks up the ID number from the record. Then I set the 
> record to false once I have the number. There has to be a better way.
> 
> TIA,
> 
> Tom
> 
> NOTICE: Medical and scientific information provided in print and 
> electronically by Sydney IVF might not be relevant to your own 
> circumstances and should always be discussed with your own doctor 
> before you act on it. This communication is confidential and may 
> contain copyright or otherwise protected information of Sydney IVF 
> Limited or a third party. If you are not the intended recipient of 
> this communication please immediately let us know by reply email or 
> telephone us on +61 2
> 9221 5964, delete the communication and destroy all copies. --- You 
> are currently subscribed to cfaussie as: [EMAIL PROTECTED] To 
> unsubscribe send a blank email to 
> [EMAIL PROTECTED] Aussie Macromedia Developers:
> http://lists.daemon.com.au/


------------------------------------------------------------------------
-----------
This e-mail is sent by Suncorp-Metway Limited ABN 66 010 831 722 or one
of its related entities ("Suncorp"). 

Suncorp may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on
1800 689 762 or at suncorp.com.au.

The content of this e-mail is the view of the sender or stated author
and does not necessarily reflect the view of Suncorp. The content,
including attachments, is a confidential communication between Suncorp
and the intended recipient. If you are not the intended recipient, any
use, interference with, disclosure or copying of this e-mail, including
attachments, is unauthorised and expressly prohibited. If you have
received this e-mail in error please contact the sender immediately and
delete the e-mail and any attachments from your system.

If this e-mail constitutes a commercial message of a type that you no
longer wish to receive please reply to this e-mail by typing Unsubscribe
in the subject line.


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To
unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/



---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to