Subject Re: [ib-support] Wrong codeflow in SP. Possible bug
Author Andrew Guts
Paul Reeves wrote:

Thank you all. I'm sorry. That is my mistake. First version of SP was
not contain nested "if". It was added later without paying necessary
attention.

Andrew

>Andrew Guts wrote:
>
>
>>Hello IB support.
>>
>>This is a fragment of my stored proc. Qty is an integer parameter. The
>>statement after "ELSE" is never executed. When I've replaced
>>"ELSE" by "if (Qty <= 0) then" it works as expected. What is wrong with it?
>>
>>
>
>The compiler just doesn't respect your indentation, does it?
>
>
>
>> 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;
>>
>>
>>
>
>What the compiler sees is this:
>
>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;
>
>Try again with the judicious use of BEGIN and END.
>
>
>Paul
>
>