title: cursor in a trigger
body: <p>I have an existing TABLE <code>postn_matrix</code> which contains a list of employees and a count of their resp. positions in the organisation.</p>
  
  <p>Whenever a position of a user is added or removed, the corresponding count is reflected in the table thro' this trigger (VIA UPDATE)</p>
  
  <p>Now, if there is a new user, he will not have an entry in <code>postn_matrix</code>, so I have to insert a new record for him/her (VIA INSERT). This needs to be brought in from the BASE TABLE.</p>
  
  <p>The update seems to be working fine but I am not able to bring in a new user into the table.</p>
  
  <p>I've been trying to handle this case with a cursor. But it hasnt been of any help yet. 
  I'm hoping some expert could show me the light.. :). any other suggestions besides using a cursor will be much appreciated</p>
  
  <pre><code>CREATE OR REPLACE TRIGGER TRIG1
  BEFORE INSERT OR DELETE ON (BASETABLE)
  FOR EACH ROW
  DECLARE
    cursor c1 is
    select person_id 
    from postn_matrix;
  
    v_temp varchar2(15);
  BEGIN
    IF INSERTING THEN
      open c1;    
      LOOP
        fetch c1 into v_temp;
  
        if v_temp!=:new.person_id THEN
          insert into POSTN_MATRIX (PERSON_ID)
          VALUES (:new.PERSON_ID);
        else
          UPDATE POSTN_MATRIX
          //this is working fine ;
  
        END IF;
      end loop;
      close c1;
  
  END
  /
  </code></pre>