13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

SQL support in local databases<br />

In addition to table triggers, an INSTEAD OF trigger can be created on a view. If one or more INSTEAD OF INSERT,<br />

INSTEAD OF DELETE, or INSTEAD OF UPDATE triggers are defined on a view, it is not considered an error to<br />

execute the associated type of statem<strong>en</strong>t (INSERT, DELETE, or UPDATE) on the view. In that case, executing an<br />

INSERT, DELETE or UPDATE on the view causes the associated triggers to fire. Because the trigger is an INSTEAD<br />

OF trigger, the tables underlying the view are not modified by the statem<strong>en</strong>t that causes the trigger to fire. However,<br />

the triggers can be used to perform modifying operations on the underlying tables.<br />

There is an important issue to keep in mind wh<strong>en</strong> creating a trigger on a table with an INTEGER PRIMARY KEY<br />

column. If a BEFORE trigger modifies the INTEGER PRIMARY KEY column of a row that is to be updated by the<br />

statem<strong>en</strong>t that causes the trigger to fire, the update doesn't occur. A workaround is to create the table with a PRIMARY<br />

KEY column instead of an INTEGER PRIMARY KEY column.<br />

A trigger can be removed using the DROP TRIGGER statem<strong>en</strong>t. Wh<strong>en</strong> a table or view is dropped, all triggers<br />

associated with that table or view are automatically dropped as well.<br />

RAISE () function<br />

A special SQL function RAISE() can be used in a trigger-step statem<strong>en</strong>t of a trigger. This function has the following<br />

syntax:<br />

raise-function ::= RAISE ( ABORT, error-message ) |<br />

RAISE ( FAIL, error-message ) |<br />

RAISE ( ROLLBACK, error-message ) |<br />

RAISE ( IGNORE )<br />

Wh<strong>en</strong> one of the first three forms is called during trigger execution, the specified ON CONFLICT processing action<br />

(ABORT, FAIL, or ROLLBACK) is performed and the curr<strong>en</strong>t statem<strong>en</strong>t's execution <strong>en</strong>ds. The ROLLBACK is<br />

considered a statem<strong>en</strong>t execution failure, so the SQLStatem<strong>en</strong>t instance whose execute() method was being carried out<br />

dispatches an error (SQLErrorEv<strong>en</strong>t.ERROR) ev<strong>en</strong>t. The SQLError object in the dispatched ev<strong>en</strong>t object's error<br />

property has its details property set to the error-message specified in the RAISE() function.<br />

Wh<strong>en</strong> RAISE(IGNORE) is called, the remainder of the curr<strong>en</strong>t trigger, the statem<strong>en</strong>t that caused the trigger to execute,<br />

and any subsequ<strong>en</strong>t triggers that would have be<strong>en</strong> executed are abandoned. No database changes are rolled back. If the<br />

statem<strong>en</strong>t that caused the trigger to execute is itself part of a trigger, that trigger program resumes execution at the<br />

beginning of the next step. For more information about the conflict resolution algorithms, see the section ON<br />

CONFLICT (conflict algorithms).<br />

DROP TRIGGER<br />

The DROP TRIGGER statem<strong>en</strong>t removes a trigger created by the CREATE TRIGGER statem<strong>en</strong>t.<br />

sql-statem<strong>en</strong>t ::= DROP TRIGGER [IF EXISTS] [database-name.] trigger-name<br />

The trigger is deleted from the database. Note that triggers are automatically dropped wh<strong>en</strong> their associated table is<br />

dropped.<br />

Special statem<strong>en</strong>ts and clauses<br />

This section describes several clauses that are ext<strong>en</strong>sions to SQL provided by the runtime, as well as two language<br />

elem<strong>en</strong>ts that can be used in many statem<strong>en</strong>ts, comm<strong>en</strong>ts and expressions.<br />

COLLATE<br />

The COLLATE clause is used in SELECT, CREATE TABLE, and CREATE INDEX statem<strong>en</strong>ts to specify the<br />

comparison algorithm that is used wh<strong>en</strong> comparing or sorting values.<br />

Last updated 6/6/2012<br />

1103

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

Saved successfully!

Ooh no, something went wrong!