title: Trigger for incrementing a date and inserting into another table
body: <p>I want to create a trigger, in Oracle. When the <code>dateOrdReceived</code> in my order table is updated or inserted the trigger takes this date whatever it may be and updates it by 14 days into another table productList ordDateDelivery so that it equals to</p>
  
  <pre><code>dateOrdReceived + 14 days = new ordDateDelivery
  </code></pre>
  
  <p>I did have a couple of attempts and guessed I'd need a query which would join my two tables. I also learned that maybe using DATEADD would allow me add 14 days but altogether I can't quite get it right.</p>
  
  <p>My trigger attempt</p>
  
  <pre><code>`CREATE OR REPLACE TRIGGER  "PRODUCTLIST_DATE_DELIVERY" 
  BEFORE
  insert or update on "PRODUCTLIST"
  for each row
  
  begin
  select p.dateOrdRecieved, o.ordDateDelivery
  from productList p JOIN orders o
  ON p.ordID = o.ordID;
  
  new.OrdDateDelivery := DATEADD(day,14,new.p.dateOrdRecieved)
  
  end;
  
  
  /
  ALTER TRIGGER  "PRODUCTLIST_DELIVERY_DATE" ENABLE
  </code></pre>
  
  <p>and my tables for this trigger are as follows</p>
  
  <pre><code>PRODUCTLIST TABLE
  
  CREATE TABLE  "PRODUCTLIST" 
  (   "ORDID" NUMBER(3,0) NOT NULL ENABLE, 
  "PRODUCTID" NUMBER(3,0) NOT NULL ENABLE, 
  "QUANTITY" NUMBER(4,2) NOT NULL ENABLE, 
  "ORDDATEDELIVERY" DATE, 
  "DISCOUNT" NUMBER(3,0), 
  "TOTALCOST" NUMBER(4,2), 
   CONSTRAINT "PK_PRODUCTLIST" PRIMARY KEY ("ORDID", "PRODUCTID") ENABLE
  )
  /
  ALTER TABLE  "PRODUCTLIST" ADD CONSTRAINT "FK_ORDERS" FOREIGN KEY ("ORDID")
    REFERENCES  "ORDERS" ("ORDID") ENABLE
  /
  ALTER TABLE  "PRODUCTLIST" ADD CONSTRAINT "FK_PRODUCTS" FOREIGN KEY ("PRODUCTID")
    REFERENCES  "PRODUCT" ("PRODUCTID") ENABLE
  /
  
  ORDERS TABLE
  
  CREATE TABLE  "ORDERS" 
  (   "ORDID" NUMBER(3,0) NOT NULL ENABLE, 
  "DATEORDRECIEVED" DATE, 
  "CUSID" NUMBER(3,0) NOT NULL ENABLE, 
   PRIMARY KEY ("ORDID") ENABLE
  )
  /
  ALTER TABLE  "ORDERS" ADD CONSTRAINT "FK_CUSTOMER" FOREIGN KEY ("CUSID")
    REFERENCES  "CUSTOMER" ("CUSID") ENABLE
  /
  </code></pre>