title: Why does code throw java.sql.SQLException: ORA-01438?
body: <p>I'm inserting data in table through this statement:</p>
  
  <pre><code>insert into CATEGORY_MASTER (
    CAT_MAS_ID, 
    DESCRIPTION, ORG_ID, STATUS, MODIFY_EMPID, LANGUAGE_ID, LG_IP_MAC)  
  values ( 
    ( SELECT COALESCE(MAX(ct.cat_mas_id), 0)+1 
      FROM category_master ct),
    'fff', 2, 'A', 52,1,'SYSTEM/127.0.0.1/NOTDEFINE')
  </code></pre>
  
  <p>The target table has this trigger:</p>
  
  <pre><code>create or replace trigger trg_aft_i_u_category_master
    after insert OR UPDATE of cat_mas_id,status on category_master FOR EACH ROW
  DECLARE
    CURSOR CSTYPE IS
      SELECT CST.SUB_TYPE_ID,CST.TYPE_ID,CST.ORG_ID,CST.STATUS
      FROM COMPLAINT_SUB_TYPE CST
      WHERE CST.ORG_ID=:NEW.ORG_ID AND CST.STATUS='A';
    V_CSTYPE CSTYPE%ROWTYPE;
  BEGIN
    IF CSTYPE%ISOPEN THEN
      CLOSE CSTYPE;
    END IF;
    OPEN CSTYPE;
    LOOP
      FETCH CSTYPE INTO V_CSTYPE;
      EXIT WHEN CSTYPE%NOTFOUND;
      if INSERTING then
        /******** Suspect issue here  *******/
        INSERT INTO CATEGORY_DETAILS(
            CAT_DTL_ID, CAT_MAS_ID, TYPE_ID ,SUB_TYPE_ID,
            ORG_ID,MAP_STATUS,MODIFY_EMPID,LANGUAGE_ID,LG_IP_MAC)
        VALUES (SEQ_CATEGORY_DETAILS.NEXTVAL,:NEW.CAT_MAS_ID, 
            V_CSTYPE.TYPE_ID,V_CSTYPE.SUB_TYPE_ID,:NEW.ORG_ID,'U',
            :NEW.MODIFY_EMPID,:NEW.LANGUAGE_ID,:NEW.LG_IP_MAC);
        /************************************/
      end if;
      if UPDATING then
        if :new.status = 'I' then
          UPDATE CATEGORY_DETAILS CD 
          SET CD.MAP_STATUS= 'U' 
          WHERE CD.CAT_MAS_ID=:NEW.CAT_MAS_ID AND CD.ORG_ID=:NEW.ORG_ID;
        end if;
      end if;
    END LOOP;
    CLOSE CSTYPE;
  end trg_aft_i_u_category_master;
  </code></pre>