0
votes

I have a form in my Oracle APEX based application, I want to have validation on submit button, so that the combination of two specific entries, if they already are present in the SQL table/View, I want to show an alert, like "The entry for this combination of values of A and B already exists, please enter correct values."

2

2 Answers

2
votes

If those two specific entries are represented by two form items (e.g. :P1_ONE and :P2_TWO), then the validation procedure might be a function that returns error text, such as

declare
  l_cnt number;
  retval varchar2(200);
begin
  select count(*)
    into l_cnt
    from your_table t
    where t.column_one = :P1_ONE
      and t.column_two = :P1_TWO;

  if l_cnt > 0 then 
     retval := 'The entry for this combination already exists';
  end if;
end;

The query itself might need to be modified, depending on what exactly you meant by describing the problem; that's the way I understood it.

1
votes

Then you should have a unique constraint on the table, and let that validate incoming data.

Any violation of this constraint will have exception raised, which can be transformed within the APEX error handling procedure.