Subject Re: How to prevent inserting?
Author vp_email@yahoo.com
--- In ib-support@y..., "Fabrice Aeschbacher"
<fabrice.aeschbacher@k...> wrote:

> Try:
> CREATE EXCEPTION PREVENT_INSERTING 'The record was not inserted
> because...';
> And then, in you trigger:
[skipped]
> EXCEPTION PREVENT_INSERTING;


> Raising an exception in a trigger
> To raise an existing exception in a trigger, use the following
syntax:
> EXCEPTION name;
> where name is the name of an exception that already exists in the
> database.

I don't want to warn a user about key violation or something else.
I just want to prevent inserting a record in the table. Without
saying a word, in silence.

>Raising an exception:
> -Terminates the trigger, undoing any changes caused (directly or
> indirectly) by the trigger.

... and undoing any changes, made in the same transaction.
I don't want undoing ALL changes. I want to fail inserting a record.
In silence.

There is a solution:
1) change ID field to "0" (zero)
2) let the record to insert
3) in the trigger "after insert" delete the record where ID = 0

That works, but makes garbage...

Are there any solutions?

--
Best regards, Vadim
vp_email@...