Hi Dan,

Thanks for your input. Since I first posted I tried the solution you suggested but I always got:

"ERROR 40XT0: An internal error was identified by RawStore module."

I've checked everything ove many times to ensure that my statement is correct and I believe it is, so is there any other reason for this error.

Thanks,

Peter.

From: Daniel John Debrunner <[EMAIL PROTECTED]>
Reply-To: "Derby Discussion" <[email protected]>
To: Derby Discussion <[email protected]>
Subject: Re: Derby Trigger Query
Date: Mon, 10 Apr 2006 10:40:21 -0700

Peter Bowman wrote:

> Hi All,
>
> I have a trigger like:
>
> DROP TRIGGER RULE_10A;
>
> CREATE TRIGGER RULE_10A
>     AFTER INSERT ON PLAN_NAME_TABLE
>     REFERENCING NEW AS NEWROW
>     FOR EACH ROW MODE DB2SQL
>     INSERT INTO PLAN_NUTRIENT_TABLE (PLAN, NUTRIENT, NUTRIENT_TYPE,
> UNITS) VALUES (NEWROW.PLAN, 'Total Fat', 'Fat', 'g');
>
>
> which inserts a new row into a table whenever a new row is inserted into
> another table, but is it possible to use a single trigger to insert
> several rows into the same table or do I have to write a separate
> trigger for each insert.

No. The VALUES clause supports multiple rows.

INSERT INTO PLAN_NUTRIENT_TABLE (PLAN, NUTRIENT, NUTRIENT_TYPE,UNITS)
VALUES (NEWROW.PLAN, 'Total Fat', 'Fat', 'g'),
       (NEWROW.PLAN, 'Marmite', 'Vitamin B', 'mg');

See

http://db.apache.org/derby/docs/10.1/ref/rrefsqlj11277.html

Dan.





Reply via email to