I have a strange problem:
We have some machines (lab automation) which I have programmed with D7
sp1, DBXpress,
Interbase 7.5. Almost all database actions are done via TSQLQuery/
TSQLDataset + TDatasetprovider + TClientdataset combination. Each app
has a thread with a second connection to the database. Because
of many actions and updates, I use manual transactions (start/commit)
for some parts with many updates.
Machines running in Windows XP SP2. Interbase running on W2003 server.
All running fine. However, now and then I get an error on a SELECT
statement: "SQL Server Error: deadlock".
Also sometimes on updating some data in database, which can occur of
course with multiple users.
But why on a select statement!? I have the following select:
------------------------------------------------------------------------------------------
select c.id, c.workstation_id,
c.destination_workstation_id,
c.next_process_step_id,
c.position_in_stack, c.stack_id, c.state,
s.row_id, s.position_in_row
from proc_get_all_child_workstations(:workstation_id) pws
left join container c
on ( c.workstation_id = pws.workstation_id)
left join stack s
on s.id = c.stack_id
where
not c.destination_workstation_id is null or
not c.next_process_step_id is null
-----------------------------------------------------------------------------------------
proc_get_all_child_workstations is a stored procedures, which
recursively
searches for all child workstations of a parent (kind of tree).
-----------------------------------------------------------------------------------------
CREATE PROCEDURE PROC_GET_ALL_CHILD_WORKSTATIONS (
parent_ws_id integer)
returns (
workstation_id integer)
as
begin
workstation_id = parent_ws_id;
suspend;
for
select w.id
from workstations w
where w.master_workstation_id = :parent_ws_id
into :workstation_id
do begin
/*check if it has also a child, and return it (recursive!)*/
for select workstation_id
from proc_get_all_child_workstations(:workstation_id) proc
into :workstation_id do
suspend;
end
end^
-----------------------------------------------------------------------------------------
I don't understand why I get a lock conflict on this statement, just a
select!
Can anybody help?