Re: Oracle 8i - Triggers
From: Tom Dyess <hiddenfromspam_at_spam.com>
Date: Wed, 12 Mar 2003 12:41:39 -0500
Message-ID: <o9Kba.513$UB1.374_at_fe02.atl2.webusenet.com>
Date: Wed, 12 Mar 2003 12:41:39 -0500
Message-ID: <o9Kba.513$UB1.374_at_fe02.atl2.webusenet.com>
Screen of what? Try using sqlplus or svrmgrl to enter in the DDL and let me know what happens.
-- Tom Dyess OraclePower.com "Clodagh Power" <clpower_at_wit.ie> wrote in message news:3ef3892c.0303120400.17deb154_at_posting.google.com...Received on Wed Mar 12 2003 - 18:41:39 CET
> Hi,
> I am trying to implement the following trigger, and when I activate
> it, the screen simply hangs. I think the syntax is correct?
>
> CREATE TABLE artist
> (artist_id NUMBER NOT NULL,
> CONSTRAINT artist_id_pk PRIMARY KEY(artist_id),
> artist_name VARCHAR2(50));
>
> CREATE TABLE stock
> (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));
>
> CREATE TABLE custorder
> (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.