We help IT Professionals succeed at work.

oracle forms question

anumoses
anumoses asked
on
Have this code

select count(*) into v_count
  from day_off_sched
  where schedule_code = :day_off_sched.schedule_code;
If v_count > 0 then
msgbox.show('Schedule Error ', 'The Schedule you entered already exixts.', 'OK');
       :day_off_sched.schedule_code := null;
          raise form_trigger_failure;      
Else      

go_item('day_off_sched.description');      
End if;
-----------
I want this code to fire only on inserting record . not when we query records .
I have this code on key-enter of the schedule code.
Comment
Watch Question

Database Developer & Administrator
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2012
Commented:
I think you have the wrong trigger,  you don't want it to be on key press trigger but instead on

"when-new-record-instance"  or maybe "when-create-record"

I don't have forms to test with though
CERTIFIED EXPERT
Commented:
I also agree with sdstuber, you should have it on "when-create-record" as in "When-New-Record-Instance"  will do the action immediately when your input moves to an item in a different record but as per you  this code should fire only on inserting record.

Author

Commented:
I tried the code in when-create-record of the block but did not fire the error.
 My code is

Declare

v_count number;      

Begin

select count(*) into v_count
  from day_off_sched
  where schedule_code = :day_off_sched.schedule_code;
 
If v_count > 0 then
        
msgbox.show('Schedule Error ', 'The Schedule you entered already exixts.', 'OK');
       :day_off_sched.schedule_code := null;
          raise form_trigger_failure;      
Else      

go_item('day_off_sched.description');      
End if;      
End;
Sean StuberDatabase Developer & Administrator
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2012

Commented:
if new record create didn't work,   did you try when new record instance?

Author

Commented:
when-new-record-instance did not work either.

Author

Commented:
thanks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.