title: Update table procedure in oracle
body: <p>I have 3 table which are</p>
  
  <p>Item : <strong>Item_Number PK</strong>, Item_Name, Current_Price,Production_cost.</p>
  
  <p>Ingredient : <strong>Ingredient_Number PK</strong>, Ingredient_Name, Ingredient_Cost</p>
  
  <p>Item_Ingredient: <strong><em>Item_Number PK/FK, Ingredient_Number PK/FK</em></strong>, Quantity_Needed</p>
  
  <p>1 Item is made by 3 or 4 different ingredients.
  Production_Cost for each Item is calculate by the sum of all (ingredient_Cost * Quantity_Needed).
  I'm trying to create the procedure with the cursor to update the Production_cost fo all item if the Production-Cost &lt; sum of all (ingredient_Cost * Quantity_Needed).But i dont't know how to calculate that in my procedure.
  Can you guys help me to fix it? This is the first part of my code:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE PR_Check_Cost
  AUTHID CURRENT USER 
  IS
  V_Production_Cost item.Production_cost%Type;
  V_New_Production_Cost number (6,2);
  V_Item_Number number (5,0);
  Cursor C_Cost IS
   select ii.item_number, SUM(in.ingredient_cost * ii.quantity_Needed)
   from item.ingredient ii, ingredient in
  where ii.ingredient_number = in_ingredient_number
  group by ii.item_number
  Begin
  Open C_Cost;
  Fetch C_Cost into V_Item_Number, V_New_Production_Cost;
   While C_Product_Cost%FOUND LOOP
  select Production_Cost
  into V_Production_Cost
  From Item
  Where Item_Number = V_Item_Number;
  
  If V_Production_Cost &lt; V_New_Production_Cost THEN
   UPDATE Item
   Set Production_Cost = V_New_Production_Cost
   Where Item_Number = V_Item_Number;
  End If;
  
  Fetch C_Cost into V_Item_Number, V_New_Production_Cost;
   End loop;
  Close C_Cost;
  End PR_Check_cost;/
  SHOW ERRORS;
  </code></pre>