473,376 Members | 1,067 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,376 software developers and data experts.

Record Locking in Access ADP

I'm trying to figure out what happened.

I have have two Tables in SQLServer called "Contacts", and "Jobs"

Whenever someone changes a record in either table I update two fields
called "Modby" and "Moddt" with a trigger. The Trigger may also
contain other things as well.

Here's the wierd thing.

If the Modby Moddt statement is the first statement in the trigger I
don't get a "record changed by another user" but if it comes later in
the trigger I do.

I think it has something to do with the LockDelay Key but I'm not sure.

Any Ideas?

Jul 23 '05 #1
3 1739
Here's some more detail.

This Trigger causes the problem:
CREATE TRIGGER RnC_CONT_Contacts_Mod
ON dbo.RnC_CONT_Contacts
FOR Insert, update
AS

-- Update Add by and Add Date
update m set
cnt_addby=dbo.fnc_getcurrentuserid(),
cnt_adddt=getdate()
from (rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id)
left join deleted d on m.cnt_id=d.cnt_id
where isnull(d.cnt_id,0)=0

-- Update Mod by and Mod Date
update m set
cnt_modby=dbo.fnc_getcurrentuserid(),
cnt_moddt=getdate()
from rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id

But modified like this the problem goes away:
This Trigger causes the problem:
CREATE TRIGGER RnC_CONT_Contacts_Mod
ON dbo.RnC_CONT_Contacts
FOR Insert, update
AS

-- Update Mod by and Mod Date
update m set
cnt_modby=dbo.fnc_getcurrentuserid(),
cnt_moddt=getdate()
from rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id

-- Update Add by and Add Date
update m set
cnt_addby=dbo.fnc_getcurrentuserid(),
cnt_adddt=getdate()
from (rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id)
left join deleted d on m.cnt_id=d.cnt_id
where isnull(d.cnt_id,0)=0

Jul 23 '05 #2
I know this wasn't clear. Maybe my typing. Let me try again.

I have one Table for Contacts.

Whenever a record changes I use the triggers above to update the
cnt_modby and cnt_moddt fields.
Whenever a record is added I use the same triggers to update the
cnt_addby and cnt_adddt fields.

If I put the Mod by fields first there's no problem but if I put the
Addby fields first I get a message that the record was changed by
another user.

Why would just changing the order make a difference?

Jul 23 '05 #3
The first thing I would sort out is trigger recursion.

Do you have nested triggers turned off?

If not, I would expect recursion problems with your internal updates, which
I would catch with

IF ( (SELECT trigger_nestlevel( object_ID('RnC_CONT_Contacts_Mod') ) ) > 0 )
BEGIN
--track mod by and addby code here
END

"IndianaJonesWB" <jr***@lcra.org> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Here's some more detail.

This Trigger causes the problem:
CREATE TRIGGER RnC_CONT_Contacts_Mod
ON dbo.RnC_CONT_Contacts
FOR Insert, update
AS

-- Update Add by and Add Date
update m set
cnt_addby=dbo.fnc_getcurrentuserid(),
cnt_adddt=getdate()
from (rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id)
left join deleted d on m.cnt_id=d.cnt_id
where isnull(d.cnt_id,0)=0

-- Update Mod by and Mod Date
update m set
cnt_modby=dbo.fnc_getcurrentuserid(),
cnt_moddt=getdate()
from rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id

But modified like this the problem goes away:
This Trigger causes the problem:
CREATE TRIGGER RnC_CONT_Contacts_Mod
ON dbo.RnC_CONT_Contacts
FOR Insert, update
AS

-- Update Mod by and Mod Date
update m set
cnt_modby=dbo.fnc_getcurrentuserid(),
cnt_moddt=getdate()
from rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id

-- Update Add by and Add Date
update m set
cnt_addby=dbo.fnc_getcurrentuserid(),
cnt_adddt=getdate()
from (rnc_cont_contacts m inner join inserted i on m.cnt_id=i.cnt_id)
left join deleted d on m.cnt_id=d.cnt_id
where isnull(d.cnt_id,0)=0

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ryan | last post by:
I have a problem with record locking / blocking within an application. The app is quite straight forward. Written in Delphi 5 using BDE to access a SQL 7 database (Win2K server). Every so often...
1
by: Fardude | last post by:
ACCESS 97, Pessimistic Record Locking!??? Does Access 97 allow record level Pessimistic locking? In other words, when user A is editing a record (has it locked) and User B tries to edit it...
0
by: Megan | last post by:
Hi- I have a question about the Microsoft Access Record-Locking Information Icon. Whenever I, or my friends, open my MS Access database, the Microsoft Access Record-Locking Information Icon...
0
by: ethanj /personal/ | last post by:
We are using Access 2000 database, with the following settings. Tool > Options > Advance > Default Record Locking = Edited Record Open databases using record level locking = True Form...
0
by: Deano | last post by:
I use the Access 2000 MSI Wizard from Sagekey and they don't know if the bug documented on page 32 of the Access 2000 Developer`s Handbook Volume 2: Enterprise Edition still affects the runtime. ...
2
by: Deano | last post by:
I use the Access 2000 MSI Wizard from Sagekey and they don't know if the bug documented on page 32 of the Access 2000 Developer`s Handbook Volume 2: Enterprise Edition still affects the runtime. ...
1
by: wheel | last post by:
I have been ok with optimistic locking most of the time but I have a situation now where there is more of a chance that users could try to edit a record at the same time. I'd like to use pessimitic...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
0
by: Cindy Huyser | last post by:
I have an Access 2000 database behind a threaded Java application that that can have have concurrent access to the same table (but not the same record). The database is set up for shared access...
3
by: kstevens | last post by:
I have turned on record locking do to the fact that we are starting to have issues with the records not being locked. I have a button on a form that changes the recordsource of the form. When i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.