Home » Developer & Programmer » Forms » Where to validate a foreign key?
Where to validate a foreign key? [message #208641] Mon, 11 December 2006 11:38 Go to next message
orate
Messages: 16
Registered: September 2005
Junior Member
I have a base table block in which three of the items (a,b,c) are a foreign key.
Where to validate the foreign key?

  1. Only in the when-validate-record?
  2. or also in the when-validate-item on each one?
    1. When the last item is filled
      (W-V-I on each one)
      
      if :a is not null and :b is not null and :c is not null then
         select count(*) into cnt
         from T 
         where a = :a and b = :b and c = :c;
      
         if cnt = 0 then
            alert
            raise form_trigger_failure?
         end if;
      end if;
      
    2. Immediately after fill any of the items
      (W-V-I on :a)
      
      if :a is not null then
         select count(*) into cnt
         from T 
         where a = :a 
               and (b = :b or :b is null)
               and (c = :c or :c is null);
      
         if cnt = 0 then
            alert
            raise form_trigger_failure?
         end if;
      end if;
      
    And, in these cases, make the trigger fail in order to force the user to correct that item? Or let the user to correct any of them?
Re: Where to validate a foreign key? [message #208679 is a reply to message #208641] Mon, 11 December 2006 21:28 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You can let Oracle do it for you at the database level but using the three item validations and the record validation is the way that I have usually seen it done.

David
Previous Topic: Find Form property code
Next Topic: I have a little problem with the default exit button..
Goto Forum:
  


Current Time: Wed Dec 07 04:59:37 CST 2016

Total time taken to generate the page: 0.06331 seconds