Home » Developer & Programmer » Forms » When-Validate-Item (Forms 10g)
When-Validate-Item [message #588196] Sun, 23 June 2013 03:26 Go to next message
MahdiAbuHassan
Messages: 7
Registered: May 2013
Location: Bahrain
Junior Member
I am trying to write the below trigger. when I run the form it does not see the trigger


Declare status Char(1);
begin
:CNT_BLK.msgfld:='';
Select CRF_Status into status
from Contract_reference
Where CRF_Contract_No = :b010.CRF_Contract_No;
If status is not null then
:CNT_BLK.msgfld:='Contract is already exists!';
raise form_trigger_failure;
end if;
Exception
When no_data_Found then
null;
end;

I have the below Key-Next-Item trigger. It works fine but I need to check if the user is adding a new duplicate contract number but I am unable to get the solution.

begin
:cnt_blk.msgfld :='';
if :Global.Click_Flag = 'ADD' then
If :CRF_Contract_No is null or length(:CRF_Contract_No)<10 then
:cnt_blk.msgfld := 'Please enter Contract No. (Format RPD-99/999). ';
raise form_trigger_failure;
else
:cnt_blk.msgfld :='';
contract_no;
end if;
end if;
if :system.mode = 'ENTER-QUERY' then
If :CRF_Contract_No is null or length(:CRF_Contract_No)<8 then
:cnt_blk.msgfld := 'Please enter valid Contract No. (Format RPD-99/999). ';
else
:cnt_blk.msgfld :='';
-- next_item;
end if;
end if;
end;
Re: When-Validate-Item [message #588213 is a reply to message #588196] Sun, 23 June 2013 15:00 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Remove/fix exception handler and run the form again. Duplicates aren't fetched with NO-DATA-FOUND but DUP-VAL-ON-INDEX.
Re: When-Validate-Item [message #588248 is a reply to message #588213] Mon, 24 June 2013 04:08 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Littlefoot wrote on Sun, 23 June 2013 21:00
Remove/fix exception handler and run the form again. Duplicates aren't fetched with NO-DATA-FOUND but DUP-VAL-ON-INDEX.


There's nothing wrong with exception handler. If a record with the same CRF_Contract_No exists then that code should raise an error. If it doesn't nothing should happen. Also you're never going to get dup_val_on_index from a select.

The obvious question is - is CRF_Status not null and char(1)?
Re: When-Validate-Item [message #588403 is a reply to message #588248] Tue, 25 June 2013 10:25 Go to previous message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Whoa, how did I manage to put that much nonsense into a single line? I apologize, that rubbish of mine is wrong from A to Z.
Previous Topic: Opening different forms in Same frame
Next Topic: Error WUF-201 and WUF-200, when open or read file
Goto Forum:
  


Current Time: Tue Jul 02 03:05:18 CDT 2024