Tag Archives: validation

Apex Validations for Tabular Reports (4.1 or any version)

There is a lot of misdirection out there in Googleland about Apex validations and how they are much nicer since version 4.1 yadda yadda.  For Tabular Reports ignore this advice.  After half a day of searching my conclusion is when dealing with validations for Tabular Reports you should stick with the old way of iterating through all rows in your report.

After being redirected a couple of times to the examples I finally looked them up.

So to skip to the meat of the advice – for tabular reports you still need to identify your report column and validate the whole report using the old fashioned way.  So step by step this means creating a validation:

1. Page Processing -> Validations -> Create

and then:

2. Page Level Validation -> PL/SQL -> PL/SQL Expression

and then create  body similar to this:

DECLARE
   l_error   VARCHAR2 (4000);
BEGIN
   FOR i IN 1 .. apex_application.g_f03.COUNT
   LOOP
      IF     LENGTH(NVL (apex_application.g_f03 (i), ”)) > 4
      THEN
         l_error :=
               l_error
            || ‘</br>’
            || ‘Row ‘
            || i
            || ‘:  This value ‘
            || apex_application.g_f03 (i)
            || ‘  can only be of length four’;
      END IF;
   END LOOP;

   RETURN LTRIM (l_error, ‘</br>’);
END;

Ensure that enboldened column number above points to the column you want to validate and obviously modify your logic accordingly.  This solution plays nicely with MRU in Apex 4.1 and as I say, after a few wasted hours, I’ll be using this page again in the near future I think!