467,179 Members | 1,231 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

To create a trigger

Hi, everyone, I am new here ...

I have a problem to create a after-trigger (update).

Example tables:

CREATE TABLE R
(
log_num SMALLINT NOT NULL,
int_num SMALLINT NOT NULL,
beg_time TIME NOT NULL,
end_time TIME NOT NULL,

PRIMARY KEY (log_num, int_num),

FOREIGN KEY skrbi(br_int) REFERENCES I (int_num)
);

CREATE TABLE I
(
int_num SMALLINT NOT NULL,
name CHAR(50) NOT NULL,

PRIMARY KEY (br_int),
);

CREATE TABLE S
(
mat_num SMALLINT NOT NULL,
cost NUMERIC(7,2) NOT NULL,
stored NUMERIC(7,2) NOT NULL WITH DEFAULT 0,

PRIMARY KEY (br_mat),
);

CREATE TABLE IS
(
int_num SMALLINT NOT NULL,
mat_num SMALLINT NOT NULL,
norm NUMERIC (7,2) NOT NULL,

PRIMARY KEY (int_num, mat_num),

FOREIGN KEY fks(mat_num) REFERENCES S (mat_num),
FOREIGN KEY fki(int_num) REFERENCES I (int_num)
);

I 1-many IS
S 1-many IS
R many-1 I


When I insert new row into the table R, the adequate rows in table S should be updated. Few or one corresponding fields of column stored (table S) should be less for the size of the few or one corresponending norm (table IS).

I am trying to write an update trigger that will send one or few (depends of the values of table IS) fields from one table (IS) to update one or few fields in another table (S, multiple rows though).



Sorry if I asked something easy or stupid i am new to this, and my english is not so good.
Jul 27 '07 #1
  • viewed: 853
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Darren | last post: by
1 post views Thread by Lisa Tang | last post: by
4 posts views Thread by SAEED BASUDAN | last post: by
2 posts views Thread by Tborn2b | last post: by
3 posts views Thread by Andrea MF | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.