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 Kristian Waagan <kr...@oracle.com> on 2010/09/08 17:39:34 UTC

Re: Create trigger with 2 sql statements

  On 23.08.10 11:52, Andrzej Kasprzyszyn wrote:
> Hi All
>
> I would like to create following trigger
>
> CREATE TRIGGER COUNTRY_TRG
> AFTER INSERT ON COUNTRY
> DELETE FROM aTable WHERE table_name = 'country'
> INSERT INTO aTable(table_name, msg) VALUES('country', current_timestamp)
>
>
> I am receiving syntax error:
>
>   11:40:55  [CREATE - 0 row(s), 0.000 secs]  [Error Code: -1, SQL
> State: 42X01]  Syntax error: Encountered "INSERT" at line 4, column 1.
> ... 1 statement(s) executed, 0 row(s) affected, exec/fetch time:
> 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]
>
>
> Is it possible that Derby doesn't allow two sql statements in triggers action?

Hi Andrzej,

Yes, you can only specify a single SQL statement. If you want to do 
more, I think you have to write (and make available) a Java stored 
procedure and use CALL PROCEDURE in your trigger.


Regards,
-- 
Kristian

> Thanks in advance,
> Andrzej