Search code examples
oracle-apexoracle-apex-5oracle-apex-5.1

how do i Disable AJAX error window for constraint?


I have an app where an AJAX error window pops up when a constraint for data. I want this AJAX error to not show up. It only does it for one of the fields in the table and not others with similar constraints. Is there a way to get rid of this window?


Solution

  • The error usually appears when a certain process fails due to your constraint exception. You can either supply an own error message (this will simply replace the constraint message) or handle the exception yourself, like this:

    declare
        lExConstraint exception;
        pragma exception_init(lExConstraint, -2290);
    begin
        insert into your_table(columnx) values (1);
    exception
        when lExConstraint then
            -- do your handling here
            null;
    end;        
    

    In this example, I created an alias for ORA-02290, a check constraint exception - but it could be used in a similar way for all other exceptions. Note that you should not leave the code like this, as it will simply swallow the exception and do nothing.