By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,850 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,850 IT Pros & Developers. It's quick & easy.

To create a trigger

P: 1
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
Share this question for a faster answer!
Share on Google+

Post your reply

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