title: Oracle PL/SQL Trigger to update another column
body: <p>I am trying to create a trigger that updates another table with PL/SQL and I am having some problems. (I have read <a href="https://stackoverflow.com/questions/4588180/sql-trigger-to-update-another-table">this</a> but doesn't help a lot). </p>
  
  <p>Here is my situation, I have lets say 2 tables :</p>
  
  <p><strong>Customers</strong> Table</p>
  
  <blockquote>
    <p><strong>CustomerID</strong> number Primary Key, <strong>ItemsDelivered</strong> number</p>
  </blockquote>
  
  <p><strong>Items</strong> Table</p>
  
  <blockquote>
    <p><strong>CustomerID</strong> number, <strong>ItemID</strong> number, <strong>ItemDelivered</strong> Varchar(15)</p>
  </blockquote>
  
  <p>Lets say that when somenone places an order we have a new record at Items table that looks like this: </p>
  
  <pre><code>| CustomerID | ItemID | ItemDelivered | 
  |         1  |    1   |    False      |
  </code></pre>
  
  <p>I want a trigger that will raise the ItemsDelivered counter whenever someone updates the ItemDelivered collumn to "True".</p>
  
  <pre><code>create or replace Trigger UpdateDelivered  
     After Update On Items For
       Each Row 
  Declare  
     Counter Customers.ItemsDelivered%Type; 
  Begin
    If (:Old.ItemDelivered ='False' And :New.ItemDelivered='True') Then
       Select ItemsDelivered into Counter From Customers where CustomerdID =:New.CustomerID; 
       Update....
    end if; 
  END;
  </code></pre>
  
  <p>Here is my problem, if only the ItemDelivered column is updated there is no New.CustomerID! </p>
  
  <p>Is there any way to get the CustomerID of the row that have just updated? 
  (I have tried to join with inserted virtual table but I am getting an error that the table doesn't exists) </p>