You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Bassam Jabbour <ba...@student.ecp.fr> on 2008/06/09 00:07:39 UTC

Checking for integrity in a trigger

Hi,

I am trying to set up a trigger in an SQL script that will check for
some complex integrity constraint on row insertion, but I couldn't get
it to work neither with IF or WHEN nor with CHECK: I am getting a syntax
error when loading the script with ij.

Am I missing something, or is it yet unimplemented in Derby?

Thanks,
-- 
Bassam Jabbour >Baz<

Re: Checking for integrity in a trigger

Posted by Rick Hillegas <Ri...@Sun.COM>.
Hi Bassam,

Derby's trigger syntax is described in the "CREATE TRIGGER statement" 
section of the Derby Reference Manual: 
http://db.apache.org/derby/docs/10.4/ref/

You may also be able to implement the behavior you need by using a CHECK 
constraint which invokes a function. The function, in turn, can do 
something complicated such as reading other tables. This will work if 
the condition you need to enforce is one which you want to hold true at 
UPDATE time as well as INSERT time.

Hope this helps,
-Rick

Bassam Jabbour wrote:
> Hi,
>
> I am trying to set up a trigger in an SQL script that will check for
> some complex integrity constraint on row insertion, but I couldn't get
> it to work neither with IF or WHEN nor with CHECK: I am getting a syntax
> error when loading the script with ij.
>
> Am I missing something, or is it yet unimplemented in Derby?
>
> Thanks,
>