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 Mamatha Kodigehalli Venkatesh <Ma...@ness.com> on 2010/06/21 10:56:26 UTC

URGENT HELP NEEDED: Trigger to update column of one table based on insert to an another table

Hello,

 

Derby version = db-derby-10.5.1.1

 

I need to pick up the value of myTable.size as soon as the record is inserted and need to update the targetable.size column 

Where myTable .myTableID = targetable.MyTableID using a Trigger.

 

Please help me out on this.

 

CREATE TABLE myTable (

myTableID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),

Name     VARCHAR (50),

size INTEGER NOT NULL);

 

INSERT INTO myTable (name,size) VALUES ('Jon231232', 9);

INSERT INTO myTable (name,size) VALUES ('Mamatha', 7);

INSERT INTO myTable (name,size) VALUES ('Star', 4);

 

 

CREATE TABLE targetTable (

targetTableID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),

myTableID INTEGER NULL,

size INTEGER);

 

Thanks

Mamatha