Reputation: 61
I have created a validation for a text field in my application. The text field is "Location." It has a unique constraint and when you enter an existing location it will give you an ORA- error message. Instead of this, I want to display a field inline error message. I did the following.
This does exactly what I want but when I try to create a new location, it also gives me this error message. What can I do to have it only affect the locations that already exist?
Upvotes: 2
Views: 3439
Reputation: 142743
Well, you never actually control whether location you're entering right now already exists in the table.
I'd suggest the following:
PL/SQL Function Body:
declare
l_loc your_table.location%type;
begin
select location
into l_loc
from your_table
where location = :P3_LOCATION;
return ('Location already exists');
exception
when no_data_found then null;
end;
Display position: Inline with field
Upvotes: 1