On 27-07-2026 17:34, Luigi Siciliano wrote:
> If I modify my procedure like this:
>
> FOR SELECT
...
> DO
> SUSPEND;
> BEGIN
> if (SALDO < 0.00) THEN EXIT;
> end
>
> I obtain all rows regardless that :SALDO > 0.00 or :Saldo < 0.00.
That is because as written that BEGIN / END block is not related to the
FOR SELECT, but a top-level standalone block that is executed *after*
your FOR SELECT completes.
After the DO must follow either a *single* statement (the SUSPEND in
your code) _or_ a BEGIN/END block.
So, you need to use:
FOR SELECT ...
DO
BEGIN
SUSPEND;
if (SALDO < 0.00) THEN EXIT;
END
> If I modify my procedure Like this:
>
> FOR SELECT
...
> DO
> BEGIN
> if (SALDO < 0.00) THEN EXIT;
> SUSPEND;
> end
>
> I obtain only rows that :Saldo > 0.00
That is because you exit before that row with SALDO < 0.00 is output
(that is what SUSPEND does).
> If I modify the procedure like this:
>
> FOR SELECT
...
> DO
> BEGIN
> if (SALDO < 0.00) THEN
> SUSPEND;
> end
>
> I obtain only rows that :SALDO < 0.00
That is because now you SUSPEND (output) *all* rows that are >= 0.00,
and don't exit at the first row that is < 0.00.
Mark
--
Mark Rotteveel