title: Getting Error in making logic of Trigger in Oracle
body: <p>we have 1:N relationship between Sales_order and Line_item. In the relationship, whenever a new item is inserted into Line_Item table, the “total” attribute of sales_order table needs to be updated. That is. Sales_Order.total =sum(all the line_item.subtotal)</p>
  <p>Write a trigger that automatically updates line_item.subtotal value by quantity*actual_price  for INSERT or UPDATE on LINEITEM table.</p>
  <p>I am trying to write Trigger Logic but is not working. Check my logic where I am doing mistake...</p>
  <pre><code>CREATE OR REPLACE TRIGGER create_subtotals  
  BEFORE INSERT OR UPDATE ON LINE_ITEM 
  for each row
  DECLARE 
    new_subtotal  number;
  BEGIN
  
    SELECT subtotal INTO new_subtotal FROM LINE_ITEM WHERE order_id = :new.order_id;
    :new.subtotal := :new.quantity * new.actual_price 
  END;
  /
  </code></pre>