Subject RE: [firebird-support] Delete trigger trickery
Author Alan McDonald
> G'day all,
>
> Is there anything wrong with this trigger....
>
> CREATE TRIGGER LEVELS_TG_BD FOR LEVELS
> BEFORE DELETE
> AS
> begin
> if (exists(select 1 from JOBS where LVL = old.LVL)) then
> exception CANT_DELETE_LEVEL;
> end^
>
> The exception fires every time I try to delete a row from LEVELS,
> even when there's patently no JOBS entry using that LEVEL.
>
> Thanks,
> Steve
> FB 1.5.2.4731

you'll always be able to select 1 from a table.
Try
select first 1 from JOBS
Alan