Re: Which triggers to use?

From: Rohrbacher, Boris <rohbo_at_sbox.tu-graz.ac.at>
Date: Mon, 29 Jun 1998 23:25:20 +0200
Message-ID: <35980640.6BD49C42_at_sbox.tu-graz.ac.at>


Hi chris

chris.rasmussen_at_usa.net wrote:

> I am still in the process of getting used to Oracle's (Forms 4.5) triggers.
>
> I have a date field called date_received.
> I have an alert that is set up with style Stop, one button (OK).
>
> When the person enters a new record, I would like to have the user notifed of
> any errors right there and then (without even moving off the record). If I
> use a When-New-Item instance as a trigger on this item, the only time this
> fires is as I either move onto (as in an edit mode) or when I move back onto
> after entering it (as in Add mode).
>
> When the person goes to save the record, I'd like for this trigger to fire,
> and then put the person in the field that needs to be corrected. So, I set
> up a When_Validate_record trigger that should fire whenever I begin to save
> the record. My alert will fire, but it doesn't acutally stop the action and
> insist on a corect date (it just goes ahead and saves the record as is after
> the message.)
>

I guess that you only do the alert. But stop forms from continuing you have to let the trigger fail. Like this :

declare
 dummy_botton integer ;

begin

  if not check_date_function( :BLOCK.DATE_RECEIVED_ITEM ) then -- assume function gives TRUE when received date is ok otherwise FALSE

   dummy_botton := show_alert( 'YOUR_ALERT_NAME')

;                            -- when FALSE => display alert to let  user know

-- raise trigger failure  to let forms know
   raise form_trigger_failure ;                -- This will let the
when-validate fail : if when validate fails focus is set back to the item that failed !
 end if;

end ; Received on Mon Jun 29 1998 - 23:25:20 CEST

Original text of this message