Thursday, 28 June 2012

APEX Tabular Form and ORA-01403: no data found

If you get the "ORA-01403: no data found" error after running your code while updating or validating a tabular form, you will need to find out which array is causing it. This error occurs if the referenced array does not exist - apex_application.g_f01..g_f50. For example, if you use a PL/SQL block similar to this:
DECLARE
   vrow   BINARY_INTEGER;
BEGIN
   FOR i IN 1 .. apex_application.g_f01.COUNT
   LOOP
      vrow := apex_application.g_f01 (i);

      UPDATE dept
         SET dname = apex_application.g_f04 (vrow),
             loc = apex_application.g_f05 (vrow)
       WHERE empno = apex_application.g_f02 (vrow);
   END LOOP;
END;
The easiest way to debug is to use:

1. Firefox
2. Firebug

Activate the firebug and use the HTML option to go over the elements (columns) in your tabular form. Firebug will show the associated array number and you can use that information to correct you code.

4 comments:

Patrick said...

Hi

Is there a way to validate if an array exist ? For instance, if you have an apex collection with different cascading LOV, some of them are empty until the user hits the previous LOV. You want to validate that all the fields have been entered on Submit.

Denes Kubicek said...

You can put a block inside your code with exception handling.

Patrick said...

Thanks for your quick reply...Do you have a quick example of the code and where do you put it. For instance, i want to validate if (apex_application.g_f04 (i)) exist, if not I want to force the user to enter the value.

Thanks again

Denes Kubicek said...

BEGIN
FOR i IN 1 .. apex_application.g_f02.COUNT
LOOP
DECLARE
v_value VARCHAR2 (4000);
v_error VARCHAR2 (4000);
BEGIN
v_value := apex_application.g_f04 (i);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_error := 'Array doesn''t exist.';
RETURN v_error;
END;
END LOOP;
END;