23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CREATE TRIGGER<br />

24<br />

Authorization<br />

CREATE TRIGGER<br />

Syntax<br />

Must have DBA privilege, RESOURCE privilege or SELECT privilege.<br />

Related statements<br />

DROP TABLE<br />

Creates a trigger for the specified table. A trigger is a special type of automatically executed<br />

stored procedure that helps ensure referential integrity for a database.<br />

Triggers contain Java source code that can use <strong>SQL</strong> Java classes to carry out database<br />

operations. Triggers are automatically activated when an INSERT, UPDATE, or DELETE statement<br />

changes the trigger’s target table. The Java source code details what actions the trigger takes<br />

when it is activated.<br />

CREATE TRIGGER [ owner_name.]trigname<br />

{ BEFORE | AFTER }<br />

{ INSERT | DELETE | UPDATE [ OF column_name [ , ... ] ] }<br />

ON table_name<br />

[ REFERENCING { OLDROW [ ,NEWROW ] | NEWROW [ ,OLDROW ] } ]<br />

[ FOR EACH { ROW | STATEMENT } ]<br />

[ IMPORT<br />

java_import_clause ]<br />

BEGIN<br />

java_snippet<br />

END<br />

owner_name<br />

trigname<br />

Specifies the owner of the trigger. If the name is different from the user name of the user<br />

executing the statement, then the user must have DBA privileges.<br />

Names the trigger. DROP TRIGGER statements specify the trigger name defined here. <strong>SQL</strong><br />

also uses trigname in the name of the Java class that it creates from the Java snippet.<br />

BEFORE | AFTER<br />

Denotes the trigger action time. The trigger action time specifies whether the triggered<br />

action, implemented by java_snippet, executes BEFORE or AFTER the invoking INSERT,<br />

UPDATE, or DELETE statement.<br />

INSERT |DELETE |UPDATE [ OF column_name [ , ...] ]<br />

Denotes the trigger event. The trigger event is the statement that activates the trigger.<br />

If UPDATE is the triggering statement, this clause can include an optional column list. Only<br />

updates to any of the specified columns will activate the trigger. If UPDATE is the triggering

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!