CREATE SIGNAL

Use the CREATE SIGNAL command to create a user-defined signal. When you create a signal, you define a list of data-typed attributes.

Syntax

CREATE [ OR REPLACE ] SIGNAL signal_name
 [ (signal_attribute_name data_type,...) ]
 [ COMMENT 'comment_string' ]

The signal name must be unique within the ObjectServer and comply with the ObjectServer naming conventions. You cannot create a user-defined signal with the same name as a system signal.

When you define attributes, specify the attribute name and any valid ObjectServer data type except VARCHAR or INCR.

You can add a comment following the optional COMMENT keyword.

Example

To create a signal called illegal_delete with two character string attributes, user_name and row_summary, use the command:

CREATE SIGNAL illegal_delete( user_name char(40), row_summary char(255) );

You could then create a trigger, such as the following pre-insert database trigger, to trap deletes that occur outside of standard office hours and raise this signal.

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;

The following user-defined signal trigger, which is triggered by the preceding database trigger, runs an external procedure to send mail notification of the attempted delete operation.

create trigger AFTER_HOURS_DELETE_WARNING
  group default_triggers
  priority 1
  on signal ILLEGAL_DELETE
  begin
	execute MAIL_THE_BOSS( 'User ' + '%signal.user_name ' +
'attempted to remove the row ' + %signal.row_summary + ' at ' +to_char(getdate) )
  end;