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:

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

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

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!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s