Subject | Re: [firebird-support] Cancelling an operation in a Trigger |
---|---|
Author | Martijn Tonies |
Post date | 2003-08-14T11:32:01Z |
Anand,
Example:
SET TERM ^^ ;
CREATE TRIGGER CATEGORIE_SYSTEEM FOR CATEGORIE ACTIVE BEFORE DELETE POSITION
0 AS
/*
Trigger:
Author : Martijn Tonies
Date : 28-11-2001 14:12:17
Purpose : Cancel the delete on a "system" categorie
Date :
Changed:
*/
BEGIN
if (old.SYSTEEM = 'T')
then exception DELETE_NOT_ALLOWED;
END
^^
SET TERM ; ^^
Exception "DELETE_NOT_ALLOWED" is defined as:
CREATE EXCEPTION DELETE_NOT_ALLOWED 'Systeem gegevens - mag niet worden
verwijderd.';
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com
> Is there any way in FireBird to cancel an INSERT or UPDATE orRaise an exception -
> DELETE operation from a BEFORE... trigger? For e.g. if the user
> tries to delete a row from a table and I need to do some
> validations before the row can be deleted, is there any way I
> could write a BEFORE DELETE trigger that would perform the
> validations and cancel the delete operation if a certain result
> was not found?
>
> Thanks in advance for any tips and suggestions,
Example:
SET TERM ^^ ;
CREATE TRIGGER CATEGORIE_SYSTEEM FOR CATEGORIE ACTIVE BEFORE DELETE POSITION
0 AS
/*
Trigger:
Author : Martijn Tonies
Date : 28-11-2001 14:12:17
Purpose : Cancel the delete on a "system" categorie
Date :
Changed:
*/
BEGIN
if (old.SYSTEEM = 'T')
then exception DELETE_NOT_ALLOWED;
END
^^
SET TERM ; ^^
Exception "DELETE_NOT_ALLOWED" is defined as:
CREATE EXCEPTION DELETE_NOT_ALLOWED 'Systeem gegevens - mag niet worden
verwijderd.';
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com