Example of CREATE OR ALTER TRIGGER
CREATE OR ALTER TRIGGER set_cust_no
ACTIVE BEFORE INSERT ON customer POSITION 0
AS
BEGIN
IF (NEW.cust_no IS NULL) THEN
NEW.cust_no = GEN_ID(cust_no_gen, 1);
END
CREATE OR ALTER TRIGGERCREATE OR ALTER TRIGGER set_cust_no
ACTIVE BEFORE INSERT ON customer POSITION 0
AS
BEGIN
IF (NEW.cust_no IS NULL) THEN
NEW.cust_no = GEN_ID(cust_no_gen, 1);
END
DROP TRIGGERDrops a trigger
DSQL, ESQL
DROP TRIGGER trigname
| Parameter | Description |
|---|---|
trigname |
Trigger name |
The DROP TRIGGER statement drops (deletes) an existing trigger.
DML triggers can be dropped by:
The owner of the table (or view)
Users with — for a table — the ALTER ANY TABLE, or — for a view — ALTER ANY VIEW privilege
Database and DDL triggers can be dropped by:
Users with the ALTER DATABASE privilege
DROP TRIGGERset_cust_no triggerDROP TRIGGER set_cust_no;
RECREATE TRIGGERDrops a trigger if it exists, and creates a trigger
DSQL
RECREATE TRIGGER trigname
{ <relation_trigger_legacy>
| <relation_trigger_sql>
| <database_trigger>
| <ddl_trigger> }
{<psql_trigger> | <external-module-body>}
!! See syntax of CREATE TRIGGER for further rules !!
The RECREATE TRIGGER statement creates a new trigger if no trigger with the specified name exists;otherwise the RECREATE TRIGGER statement tries to drop the existing trigger and create a new one.The operation will fail on COMMIT if the trigger is in use.
|
Warning
|
Be aware that dependency errors are not detected until the |
RECREATE TRIGGERCreating or recreating the set_cust_no trigger.
RECREATE TRIGGER set_cust_no
ACTIVE BEFORE INSERT ON customer POSITION 0
AS
BEGIN
IF (NEW.cust_no IS NULL) THEN
NEW.cust_no = GEN_ID(cust_no_gen, 1);
END