Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Oracle trigger (update another table)

Oracle trigger (update another table)

From: <weiq_at_webworks.ca>
Date: Mon, 15 Feb 1999 16:47:44 GMT
Message-ID: <7a9j3e$nn2$1@nnrp1.dejanews.com>


Hi, Friends

I am new in Oracle database trigger,I would be very grateful if anyone could let me know how to update the stock amount in stock table when a customer make a order

I wrote the trigger as the following, but it does not work



create table stock (itemno number, stockAmount number, remainAmount number, primary key (itemno))

create table orderstuff (orderno number, cust_Name varchar2(10), itemno number, unit number,primary key (orderno, itemno))

create or replace trigger mytrigger
before insert on orderstuff
for each row
DECLARE
    amount number;
BEGIN

     update stock
     set stock.remainAmount :=  :old.stock.remainAmount - :new.orderstuff.unit
     where stock.itemno = :ordersuff.new.itemno;
END;

Thanks and have nice day.

Wei

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Mon Feb 15 1999 - 10:47:44 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US