Subject Re: [IBO] Deadlock issue
Author Helen Borrie
At 08:15 AM 4/04/2007, you wrote:
>Hi
>
>I am getting a deadlock (sometimes) when I run the following code.
>
>
>ItemTypeQuery.Active := False;
>ItemTypeQuery.ParamByName('ItemRef').AsFloat :=
>FieldByName('ItemRef').AsFloat;
>ItemTypeQuery.ParamByName('RegionRef').AsFloat :=
>FieldByName('SourceReg').AsFloat;
>ItemTypeQuery.Active := True;
>
>
>The strange thing is that I have traced through the code and this code
>is not even required. ItemtypeQuery is already open and chowing the
>correct (same) details that this query should show. So in essence I am
>closing and re opening a query and getting a deadlock.

Can you please supply:

1. The SQL for ItemtypeQuery
2. The exception code and message that you get when you think you
have a deadlock


>ItemTypeQuery calls a stored procedure that returns the results. It
>runs in a readonly transaction in tiCommitted isolation level. The
>query itself is also marked as read only.

It is not necessary. Any dataset in a read-only transaction is by
nature read-only.

>The query providing data for the parameters is not being edited.

Although there's not enough info here to guess intelligently, have
you borne in mind that a selectable SP isn't "finished" until it
stops executing? What that means for your application flow is that
you must complete one invocation before you make another. So, before
closing the dataset, you will need to run to EOF.

Also I strongly recommend that you call methods directly, rather than
setting properties, to give yourself the opportunity to monitor
whether the method call succeeded.

with ItemTypeQuery do
begin
if not EOF then Last;
Close;
ParamByName('ItemRef').AsFloat :=
SomeOtherSet.FieldByName('ItemRef').AsFloat;
ParamByName('RegionRef').AsFloat :=
SomeOtherSet.FieldByName('SourceReg').AsFloat;
Open;
end;

Helen