Board index » delphi » Transaction problem, MSSQL 6.5 please help

Transaction problem, MSSQL 6.5 please help

Are you getting blocked or are you getting deadlocks?

Deadlocks: User A starts using table 1, User B starts using table 2, placing
locks on these tables or partes of these tables. User A now needs to access
table 2 and user B needs to access table 1.

This can be fixed by making sure that all tables are accesses in the same
order etc. This can usually be resolved  in the application or by using
stored procs etc to do complex inserts or updates that requred multiple
tables  to be modified.

Blocking: When SQL server places a lock on a table/page and you have to wait
to get access to that table/page.

This is more complex and you need to understand how MSSQL locks pages etc.
The online help is pretty good. You can specify select statements with
nolock for example. You can turn inserts for row level locking on or you can
revisit your implememtation logic and look for a more "resource friendly"
way of doing things.

Hope this helps
George Aligianis

 

Re:Transaction problem, MSSQL 6.5 please help


Hi there,
I are working on Sql Server 6.5, delphi 4.0 bde 5.01. I am really bugged
with the way we get deadlock. Any time if a person is inserting a record and
other person try to query the same table, second one get hanged. I are
really bugged over this issue.
The issue is with Sql Server. If in this situation application  crashed,
there is no way to get of of this deadlock.

please help

shantanu singh
shant...@sysonline.com

Re:Transaction problem, MSSQL 6.5 please help


One basic precaution is to make sure you are not locking the tables that
you can get away with when doing a dirty read by using the NOLOCK
directive.

Example: Not locking the customer table to update an order table column.

SELECT C.Cust_ID, C.Cust_Name, O.Order_No, O.AmountDue
       FROM Customer C (NOLOCK)
            Orders O
      WHERE O.Cust_ID = C.Cust_ID

HTH

Rkr

Quote
Shantanu wrote:

> Hi there,
> I are working on Sql Server 6.5, delphi 4.0 bde 5.01. I am really bugged
> with the way we get deadlock. Any time if a person is inserting a record and
> other person try to query the same table, second one get hanged. I are
> really bugged over this issue.
> The issue is with Sql Server. If in this situation application  crashed,
> there is no way to get of of this deadlock.

> please help

> shantanu singh
> shant...@sysonline.com

Other Threads