Subject Re: Avoiding a delete
Author rodbracher
I can't use a Referential Constraint as this is the 'wrong way round'.
I am not sure how to get the trigger working properly
It should look something like :

set term ^ ;
create trigger dealer_bd for dealer before delete as
begin
if select count(*) from Table_Sales , Table_Dealer where
Table_sales.dealer = Table_Dealer.dealer > 0
then exception my_exception
end^
set term ; ^

IBcosole does not like the "Select" - can I do such a thing ?
Will the dealer parameter be of the dealer the trigger was set off
with ?
--- In ib-support@y..., "Martijn Tonies" <m.tonies@u...> wrote:
> Hi,
>
> Try either a BEFORE DELETE trigger that raises an exception
> if there are records in Table_Sales or a Referential Constraint
> that does this job for you. Check the Language Reference for
> this.
>
> Martijn Tonies
> InterBase Workbench - the developer tool for InterBase and Firebird
> http://www.interbaseworkbench.com
>
> Upscene Productions
> http://www.upscene.com
>
> "This is an object-oriented system.
> If we change anything, the users object."
>
>
> > Hi
> >
> > What is the best way to avoid deleting a record ( a dealer ) from
> > Table_Dealer
> > if its key_column is Dealer and this is a non-key column in
> > Table_Sales.
> >
> > Ie no delete if the dealer has sales.
> >
> > Thanks
> >
> > Rod