Home » Developer & Programmer » Forms » Re validating LOV in Oracle forms (Oracle forms 10G)
Re validating LOV in Oracle forms [message #674410] Sat, 26 January 2019 02:55 Go to next message
faizanbutt
Messages: 10
Registered: December 2018
Junior Member
Hi All,
I have two fields in my form, unit and Dept_code. The column unit has three values (un1,un2,un3). A LOV is made for the second column dept_code, based on the value entered in the field Unit. It is working fine for each value in the field Unit for the first time but not for the second time.
For example, I entered un1 in the unit field and the LOV of dept_code would contain values related to un1, here I selected a value and after it I changed the value in the field Unit to un2 the value in dept_code remained the same.
And it allowed the form to save it.
Here, I want to validate again because the value selected earlier in the dept_code is not for the un2.

Please suggest any way to do this.

Thanks in advance!
Re: Re validating LOV in Oracle forms [message #674421 is a reply to message #674410] Sat, 26 January 2019 12:59 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I can think of two options.

The first one requires creating WHEN-VALIDATE-ITEM trigger on the UNIT item which removes any value from DEPT_CODE item, e.g.
:block.dept_code := null;
You might want to improve it by checking whether UNIT value has changed - if not, don't remove current DEPT_CODE value. In order to do that, store UNIT item's value into a parameter (or a global variable) in WHEN-NEW-ITEM-INSTANCE or PRE-TEXT-ITEM trigger:
:parameter.old_unit := :block.unit;

WHEN-VALIDATE-ITEM would then be
if :block.unit <> :parameter.old_unit then
   :block.dept_code := null;
end if;



Another option is to create a WHEN-VALIDATE-RECORD trigger and check whether UNIT and DEPT_CODE items match; if not, raise the error. For example:
declare
  l_dept_code   dept_codes.dept_code%type;
begin
  select d.dept_code
    into l_dept_code
    from dept_codes d
    where d.unit = :block.unit
      and d.dept_code = :block.dept_code;
exception
  when no_data_found then
    message('Dept code and unit do not match');
    raise form_trigger_Failure;
end;
Re: Re validating LOV in Oracle forms [message #674444 is a reply to message #674421] Sun, 27 January 2019 23:17 Go to previous message
faizanbutt
Messages: 10
Registered: December 2018
Junior Member
Thanks sir for your kind reply. I am checking it.
Previous Topic: Dynamic Control Of rows in a excel to oracle forms importing form
Next Topic: How to handle duplicate value in oracle forms at runtime.
Goto Forum:
  


Current Time: Thu Mar 28 09:02:41 CDT 2024