Home / InterSystems SQL Reference / SQL Commands / DROP TRIGGER

InterSystems SQL Reference
Previous section           Next section
InterSystems: The power behind what matters   

Deletes a trigger.
DROP TRIGGER name [ FROM table ]
name The name of the trigger to be deleted. A trigger name may be qualified or unqualified; if qualified, its schema name must match the table’s schema name.
FROM table Optional — The table the trigger is to be deleted from. If the FROM clause is specified, only the table is searched for the named trigger. If the FROM clause is not specified, the entire schema specified in name is searched for the named trigger.
The DROP TRIGGER statement deletes a trigger.
Privileges and Locking
The DROP TRIGGER command is a privileged operation. Prior to using DROP TRIGGER it is necessary for your process to have %DROP_TRIGGER administrative privilege. Failing to do so results in an SQLCODE –99 error (Privilege Violation). You can use the GRANT command to assign %DROP_TRIGGER privileges, if you hold appropriate granting privileges.
In embedded SQL, you can use the $SYSTEM.Security.Login() method to log in as a user with appropriate privileges:
   DO $SYSTEM.Security.Login("_SYSTEM","SYS")
   &sql(      )
You must have the %Service_Login:Use privilege to invoke the $SYSTEM.Security.Login method. For further information, refer to %SYSTEM.Security in the InterSystems Class Reference.
DROP TRIGGER cannot be used on a table created by defining a persistent class, unless the table class definition includes [DdlAllowed]. Otherwise, the operation fails with an SQLCODE -300 error with the %msg DDL not enabled for class 'Schema.tablename'.
The DROP TRIGGER statement acquires a table-level lock on table. This prevents other processes from modifying the table’s data. This lock is automatically released at the conclusion of the DROP TRIGGER operation.
FROM Clause
A trigger and its table must reside in the same schema. If the trigger name is unqualified, the trigger schema name defaults to the same schema as the table schema, as specified in the FROM clause. If the trigger name is unqualified, and there is no FROM clause, or the table name is also unqualified, the trigger schema defaults to the system-wide default schema name; schema search paths are not used. If both names are qualified, the trigger schema name must be the same as the table schema name. A schema name mismatch results in an SQLCODE -366 error; this should only occur when both the trigger name and the table name are qualified and they specify different schema names.
In InterSystems SQL, a trigger name must be unique within its schema for a specific table. Thus it is possible to have more than one trigger in a schema with the same name. The optional FROM clause is used to determine which trigger to delete:
The following example deletes a trigger named Trigger_1 associated with any table in the system-wide default schema. (The initial default schema is SQLUser):
The following example deletes a trigger named Trigger_2 associated with any table in the A schema.
The following example deletes a trigger named Trigger_3 associated with the Patient table in the system-wide default schema. If a trigger named Trigger_3 is found, but it is not associated with Patient, InterSystems IRIS issues an SQLCODE -363 error.
DROP TRIGGER Trigger_3 FROM Patient
The following examples all delete a trigger named Trigger_4 associated with the Patient table in the Test schema.
DROP TRIGGER Test.Trigger_4 FROM Patient
DROP TRIGGER Trigger_4 FROM Test.Patient
DROP TRIGGER Test.Trigger_4 FROM Test.Patient
See Also

Previous section           Next section
View this book as PDF
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-02-22 00:52:40