Hi,

I am trying to implement a check in my pages so that if user A is editing 
record 1 from edit form A at the same time that user B is editing record 1 
from edit form B, the user who submits it second will get an error that 
someone has just updated this record.

I have a field in my table called "status_date", which is populated with the 
sysdate every time a record is updated.

This is what I've attempted:

In each form page itself, I've immediately queried the current status date 
for the record. When I display this on the page for testing purposes, it 
displays in the format 2000-08-25 10:22:39. I then assign this value to a 
variable called "last_status_date".  Then I pass last_status_date as a 
hidden field to my action page (the page that does the updates.

Immediately in my action form (before any updates are made, I have the 
following:

<!--- immediately check status_date again to make sure no one else has 
updated it while the form was being filled out --->
<cfquery name="getstatus" datasource="CF_3IS" dbtype="ODBC">
SELECT STATUS_DATE
FROM SUG_SUGGESTIONS
WHERE SUGGESTION_ID=#URL.SUGGESTION_ID#
</cfquery>

<cfset datedifference = #getstatus.status_date#-#form.last_status_date#>
<cfif ("datedifference") LTE 0>
<cfabort showerror="Another user has just updated this suggestion. Please go 
back and refresh your browser to view the data inputted by this user, as it 
may affect your data entry.">
</cfif>

I have displayed the output of datedifference to see what is going on...

On my action page, this is what I get for output:

form last status date: 2000-08-25
status check from this page: 2000-08-25 10:40:59
difference: 0.445127314815

What is happening is that for some reason, the time portion of 
form.last_status_date is not passing with the hidden field, even though 
form.last_status_date fully displays on the form page as desired. Why would 
this be?

Also, I believe that my reasoning is flawed for what I am trying to do, 
because of the actual dates.  Should I be using different logic for 
determining if the record has been updated by user A just before user B 
submitted?

Does this make sense?

Thanks!
T
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to