title: IBM DB2 Create Trigger after insert
body: <p>i'm having trouble trying to create a trigger for my db2 database.
  this is the first time that i try to use triggers, so please forgive my stupidity.</p>
  
  <p>i have 3 tables which look like this:</p>
  
  <ul>
  <li>table arnold with columns: "id" and "use" both integer </li>
  <li>table bertram with columns: "id" integer and "name" varchar </li>
  <li>table connor with columns: "pos", "arnoldid", "bertramid" all integer</li>
  </ul>
  
  <p>now im trying to create a trigger that will automatically insert rows into table connor when a new row is inserted into table bertram.
  it has to get the id of the newly created bertram row, and insert all rows of table arnold in which use is set to 1, and put their id's into the respective arnoldid column in the connor rows.
  also the pos column in all those connor rows has to be numbered from 1 up to the number of new rows.</p>
  
  <p>i came this far, but i think its very very wrong:</p>
  
  <pre><code>CREATE TRIGGER usage AFTER INSERT ON bertram REFERENCING NEW AS newbert FOR EACH ROW
  BEGIN ATOMIC
      SET newpos = 1;
      FOR looop AS mycursor CURSOR FOR SELECT * FROM arnold WHERE (use = 1) DO
          INSERT INTO connor (pos, bertramid, arnoldid) 
                      VALUES (newpos, newbert.id, mycursor.id);
          SET newpos = newpos +1;
      END FOR;
  END
  </code></pre>
  
  <p>Thanks for any help!!!
  :(</p>