Ajax call returned server error with QMS

We are building a new Apex frontend on an existing former Oracle Forms application.  After calling some packaged procedures from en Dynamic Action we were confronted with an “Ajax call returned server error”. It seems that an exception raised by the database but invoked by a DA bypasses the central exception handler function you can set in the application properties.

The problem is, that with QMS, a lot of checks are implemented using QMS$ERRORS, so the top-error returning to the “client” is an ORA-20998.  This is not however the real message. You have to walk the error-stack to find the real error.

I have created a packaged procedure DA_ERROR  (in the package APX_VAL, but that is not that important):

PROCEDURE DA_ERROR
IS
  l_err_rec     hil_message.message_rectype;
  l_has_errors  BOOLEAN := TRUE;
  l_error       varchar2(32676);
begin
  l_error := SQLERRM;
  if ( l_error like '%-20998%' )
  THEN
    WHILE l_has_errors
    LOOP
      cg$errors.pop(l_err_rec);
      IF ( l_err_rec.msg_code IS NOT NULL )
      THEN
        l_error := l_err_rec.msg_code || ': ' || l_err_rec.msg_text;
      ELSE
        l_has_errors := FALSE;
      END IF;
    END LOOP;
    cg$errors.cg$err_tab_i := 1;
  end if;
  --
  if ( l_error is not null )
  then
    htp.p('{"error":"'||l_error||'"}');
  end if;
end;

With this procedure in place we can alter our code in :

begin
  call the old procedure
exception
  when others
  then
    apx_val.da_error;
end;

This still doesn’t show the message in the normal errorposition, but the alert that’s raised is more informative that the ORA-20998

Advertisements

One thought on “Ajax call returned server error with QMS

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