This example shows a user-defined signal called illegal_delete, and the DETECT_AN_ILLEGAL_DELETE database trigger in which it is used. The database trigger uses the signal to trap deletes that occur outside of standard office hours.
| Field | Entry |
|---|---|
| Signal Name | illegal_delete |
| Comment | To be used with the DETECT_AN_ILLEGAL_DELETE trigger. |
| Parameters | user_name Char(20) row_summary Char(20) These read-only entries in the Parameters list
are constructed from entries made in the Name, Data
Type, and Data Length fields in
the Parameters area. For example, for user_name
Char(20), the entries are:
|
In the following SQL text for the DETECT_AN_ILLEGAL_DELETE pre-insert database trigger, the raise signal command is shown in bold.
create trigger DETECT_AN_ILLEGAL_DELETE
group default_triggers
priority 1
before delete on alerts.status
for each row
begin
if( ( (hourofday() > 17) and (minuteofhour() > 30) ) or (hourofday() < 9) ) then
raise signal ILLEGAL_DELETE %user.user_name, old.Summary;
cancel;
end if;
end;
This trigger raises the illegal_delete user-defined signal. Normally, the raised signal would then be detected and acted upon, for example, by another trigger.