Ajax call returned server error ORA-01403: no data found for APEX Interactive Grid

Fahad Pasha picture Fahad Pasha · Mar 13, 2017 · Viewed 13.1k times · Source

I am trying to save data into my table using an interactive grid with the help of custom plsql. I am running into an "ORA-01403-no data found" error while inserting data and I can't figure out why.

This is my plsql custom process which I run. Appreciate your help.

DECLARE

em_id   NUMBER;

BEGIN

   CASE :apex$row_status

      WHEN 'C'
      THEN
         SELECT NVL (MAX (emergency_id), 0) + 1
           INTO em_id
           FROM emp_emergency_contact;

         INSERT INTO emp_emergency_contact
                     (emergency_id, emp_id, emergency_name, emergency_relation
                     )
              VALUES (em_id, :emp_id, :emergency_name, :emergency_relation
                     );
      WHEN 'U'
      THEN
         UPDATE emp_emergency_contact
            SET emergency_name = :emergency_name,
                emergency_relation = :emergency_relation
          WHERE emergency_id = :emergency_id;
      WHEN 'D'
      THEN
         DELETE      emp_emergency_contact
               WHERE emergency_id = :emergency_id;
   END CASE;
END;

Answer

Scott picture Scott · Mar 14, 2017

Not entirely sure. A 'select into' can raise a no_data_found exception, but yours shouldn't.

That being said, you shouldn't have max(id)+1 anywhere in your code. This is a bug. Use a sequence or identity column instead.