Oracle 8i - Triggers
Date: 12 Mar 2003 04:00:59 -0800
Message-ID: <3ef3892c.0303120400.17deb154_at_posting.google.com>
Hi,
CREATE TABLE artist
CREATE TABLE stock
CREATE TABLE custorder
I am trying to implement the following trigger, and when I activate
it, the screen simply hangs. I think the syntax is correct?
(artist_id NUMBER NOT NULL,
CONSTRAINT artist_id_pk PRIMARY KEY(artist_id),
artist_name VARCHAR2(50));
(stock_id NUMBER NOT NULL,
CONSTRAINT stock_id_pk PRIMARY KEY(stock_id),
stock_name VARCHAR2(20),
stock_artist_ID NUMBER,
CONSTRAINT stock_artist_ID_fk FOREIGN KEY(stock_artist_ID)
REFERENCES artist(artist_id),
total_in_stock NUMBER,
reorder_level NUMBER,
CONSTRAINT reorder_const CHECK(reorder_level>=50));
(custorder_id NUMBER NOT NULL,
CONSTRAINT custorder_id_pk PRIMARY KEY(custorder_id),
custord_stck_id NUMBER,
CONSTRAINT custord_stck_id_fk FOREIGN KEY(custord_stck_id)
REFERENCES stock(stock_id),
custorder_qty NUMBER);
CREATE OR REPLACE TRIGGER dec_stck
BEFORE INSERT OR UPDATE ON custorder
FOR EACH ROW
BEGIN
UPDATE stock SET stock.total_in_stock = (stock.total_in_stock -
custorder.custord_qty)
WHERE stock.stock_id = custorder.custord_stck_id; END; Any suggestions? Thanks. Received on Wed Mar 12 2003 - 13:00:59 CET