title: SQL: Statement Triggers VS For Each Row
body: <p>EDIT: I don't know what distro it is, it's in an exam paper.</p>
  
  <p>I'm just not getting this, sadly. I'm quite happy with Row level triggers but could someone explain to me how the results would differ if the trigger was statement level instead?</p>
  
  <p>Relation/Statement Trigger/Row Level Trigger</p>
  
  <pre><code>Employee(ID VARCHAR2(30), Salary NUMBER)
  
  
  Create Trigger AutoRaise
  After insert on Employee
  Referencing new table as NT
  update Employee
  Set salary = salary + (select avg(salary) from NT)
  
  
  Create trigger AutoRaise
  After insert on Employee
  Referencing new table as NT
  For each Row
  Update employee
  Set salary = salary + (select avg(salary) from NT)
  </code></pre>
  
  <p>I understand that in the for each row trigger it'll fire for each row affected by the triggering statement. Now would the statement level trigger modify the results differently? Say if I inserted five tuples in one statement, would it set the salary etc for them all? If so, what's the benefit of the row level trigger here?</p>
  
  <p>I've tried searching but I just can't get my head around it.</p>
  
  <p>Thanks,</p>
  
  <p>EDIT:  Now, I'm just being dense but would either trigger produce different outputs? For the statement level trigger if I used the example values:</p>
  
  <p>In table before trigger's creation:</p>
  
  <pre><code>(A,50)
  </code></pre>
  
  <p>Added in ONE statement after trigger is created:</p>
  
  <pre><code>(B,70), (C,30)
  </code></pre>
  
  <p>The first trigger would set the salary for each tuple being inserted, surely? So the first would become 120 (as the average is 50, 70 + 50 = 120) and the second would become 80. If this is true, how does the second trigger differ in results?</p>