title: 'Numeric or value error' during execution of trigger
body: <p>I am currently working on an application using Oracle Apex which is being used as a database to keep a record of cabling.</p>
  
  <p>When components in the database are deleted, a PL/SQL trigger is executed which deletes any associations to the components from another table (PORT) and sets the port references to 0.</p>
  
  <p>The trigger seems to work perfectly for the majority of components I attempt to delete, but presents me with a 'numeric or value error' for others and I am struggling to find out why (as shown below)</p>
  
  <p><img src="https://i.imgur.com/EsCv1Yb.png" alt="error"></p>
  
  <p>The trigger being executed looks like this:</p>
  
  <pre><code>create or replace trigger "COMPONENT_TRIGPORT" 
  AFTER delete 
      on "COMPONENT"
      for each row
  declare    
      TYPE portType IS TABLE OF PORT%ROWTYPE; 
      port_arr portType;
  begin
      DELETE FROM PORT
      where PORT.COMPONENT_ID = :old.COMPONENT_ID
      RETURNING PORT_ID, PORT_NUMBER, COMPONENT_ID, CONNECTOR_ID, PORT_TYPE
      BULK COLLECT INTO port_arr;
      begin
          FOR i IN port_arr.FIRST .. port_arr.LAST
          LOOP
              update PORT
              set PORT.CONNECTOR_ID = 0
              where PORT.CONNECTOR_ID = port_arr(i).CONNECTOR_ID;
          END LOOP;
      end;
  end;​
  </code></pre>
  
  <p>I know that the line giving me the error is </p>
  
  <pre><code>where PORT.COMPONENT_ID = :old.COMPONENT_ID
  </code></pre>
  
  <p>But I cannot work out why it works fine in some cases but not in others!</p>