Subject RE: [ib-support] Wrong codeflow in SP. Possible bug
Author Dmitry Yemanov
Andrew,

> if (Qty > 0) then
> if (exists (select docid from Closed_Docs where DocID = :d))
> then exception xcptdoc_closed;
> else
> if (exists (select DocRow from Reserves where DocRow = :DocRow
> and Term >= 'NOW' and AuthorID <> :E))
> then exception XCPT_RESERVED;

Use BEGIN..END to avoid an ambiguity in your statements:

if (Qty > 0) then
begin
if (exists (select docid from Closed_Docs where DocID = :d))
then exception xcptdoc_closed;
end
else
begin
if (exists (select DocRow from Reserves where DocRow = :DocRow
and Term >= 'NOW' and AuthorID <> :E))
then exception XCPT_RESERVED;
end


HTH,
Dmitry