Home » Developer & Programmer » Forms » Date Validation in PRE-INSERT Trigger (Windows, Oracle Forms 6i)
Date Validation in PRE-INSERT Trigger [message #576144] Fri, 01 February 2013 00:12 Go to next message
praveen240881
Messages: 36
Registered: February 2012
Member
Dear Experts
Need your guidance please. In the attached PRE-INSERT Trigger Code i need to do a validation.
Validatation:
If the Date range is between FEB 6 2013 and MARCH 1 2013 then the code should work
ELSE
It should throw a message
Can you please let me know how can i accomplish this.

Regards
Praveen

Check_Product_Title;
Begin
	if :prod2.internet_product_flag = 'Y' and :prod2.brnd_code is null then
		soft_messages('E',TRUE,'Brand code must be specified for CCH online product');
	end if;
end;	
BEGIN
	IF :PROD2.GAA_AVAIL IS NULL THEN	
		 :PROD2.GAA_AVAIL :='N';
	END IF;
END;

BEGIN
   IF (:prod2.GAA_AVAIL = 'Y' AND :prod2.INTERNET_PRODUCT_FLAG = 'N' )
  THEN
    soft_messages('E', TRUE, 'The Available in GAA flag can only be set to Yes if the CCH Canadian Online Product flag is set to Yes');
  END IF;
END;

begin
if :prod2.GAA_AVAIL='Y' then
set_item_property('prod2.GAA_AVAIL',enabled,property_false);
else
set_item_property('prod2.GAA_AVAIL',enabled,property_true);
end if;
end;

BEGIN
  Check_printable_item_flag;

  :PROD2.CREATED_BY := :CG$CTRL.CGU$USER;
  :PROD2.CREATED_DATE := SYSDATE;
  
  IF :PROD2.DELIVERY_HANDLING_CHARGE_FLAG = 'Y'
    AND :PROD2.PRODUCT_TYPE IN ('BOOK','SE','PD','BVOL','BINC')
    AND :PROD2.SHIPPING_CHARGES_SCHEME IS NULL
  THEN
    soft_messages ('W',TRUE,'The Scheme is mandatory for this product type when Shipping Charges Flag is Yes ');
  END IF;  
    
  IF :PROD2.PRODUCT_TYPE='ADDL' AND :PROD2.PRMU_CODE IS NULL    
  THEN
    soft_messages ('E',TRUE,'Multi User Pricing Group is mandatory for Additional product type');
  END IF;
  	
END;
Re: Date Validation in PRE-INSERT Trigger [message #576156 is a reply to message #576144] Fri, 01 February 2013 01:00 Go to previous messageGo to next message
Littlefoot
Messages: 19889
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What is a "date range"? Is it a sysdate? If so,
if sysdate between to_date('06.02.2013', 'dd.mm.yyyy') and to_date('01.03.2013', 'dd.mm.yyyy') then
   check_product_title;
   <the rest of your code goes here>
else
   message('Your error message goes here');
   raise form_trigger_failure;
end if;

By the way, why all these BEGIN-END blocks?
Re: Date Validation in PRE-INSERT Trigger [message #576163 is a reply to message #576144] Fri, 01 February 2013 01:17 Go to previous messageGo to next message
praveen240881
Messages: 36
Registered: February 2012
Member
Dear Littlefoot
Thanks. I tried as you suggested, but whats happening is as the Trigger is on a Data Block, it still inserts the data into the table.
Re: Date Validation in PRE-INSERT Trigger [message #576205 is a reply to message #576163] Fri, 01 February 2013 06:36 Go to previous message
cookiemonster
Messages: 11285
Registered: September 2008
Location: Rainy Manchester
Senior Member
If pre-insert fails (with raise form_trigger_failure) then insert must fail.
So presumably it isn't failing (or you have an exception handler).
Please post your current code.
Previous Topic: problem with insertion in database
Next Topic: Forms 11g Applet blank Screen
Goto Forum:
  


Current Time: Sat Dec 20 00:53:59 CST 2014

Total time taken to generate the page: 0.05891 seconds