In the "lang.html" documentation file, put the CREATE TRIGGER and DROP TRIGGER
sections in alphabetical order. (CVS 564) FossilOrigin-Name: d1d8642b57bd0765ade730248012d58b0859c12c
This commit is contained in:
parent
b38f58b51a
commit
5b87fa2a57
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sthe\sMakefile.in\sthat\swas\sforgotten\swith\scheckin\s#562\s(CVS\s563)
|
||||
D 2002-05-15T08:43:10
|
||||
C In\sthe\s"lang.html"\sdocumentation\sfile,\sput\sthe\sCREATE\sTRIGGER\sand\sDROP\sTRIGGER\nsections\sin\salphabetical\sorder.\s(CVS\s564)
|
||||
D 2002-05-15T11:43:16
|
||||
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
|
||||
F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
|
||||
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
||||
@ -127,14 +127,14 @@ F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
|
||||
F www/faq.tcl 45bdb18b75ac3aa1befec42985fb892413aac0bb
|
||||
F www/formatchng.tcl 2ce21ff30663fad6618198fe747ce675df577590
|
||||
F www/index.tcl d0c52fbf031d0a3ee6d9d77aa669d5a4b24b6130
|
||||
F www/lang.tcl a22cf9eff51e65ec5aa39b1efb5b7952d800ac06
|
||||
F www/lang.tcl be7a241fe3dbb145ff25fe951c3d8ad16b543a1f
|
||||
F www/mingw.tcl f1c7c0a7f53387dd9bb4f8c7e8571b7561510ebc
|
||||
F www/opcode.tcl bdec8ef9f100dbd87bbef8976c54b88e43fd8ccc
|
||||
F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
|
||||
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
|
||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||
P 794bf67b6b36fce8854d5daff12f21dbb943240c
|
||||
R 08d6d280437ddbf6c3512d0683d6a10e
|
||||
U danielk1977
|
||||
Z 654e041ad87e42741720cd7b74aa49a7
|
||||
P 29b8330ca6bfe32c499a045189683100f2b15246
|
||||
R a27803f7b286e7959f11eb8469f192e0
|
||||
U drh
|
||||
Z a84814eb63e1343d44fc3775f1b09115
|
||||
|
@ -1 +1 @@
|
||||
29b8330ca6bfe32c499a045189683100f2b15246
|
||||
d1d8642b57bd0765ade730248012d58b0859c12c
|
246
www/lang.tcl
246
www/lang.tcl
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Run this Tcl script to generate the sqlite.html file.
|
||||
#
|
||||
set rcsid {$Id: lang.tcl,v 1.34 2002/05/15 08:30:15 danielk1977 Exp $}
|
||||
set rcsid {$Id: lang.tcl,v 1.35 2002/05/15 11:43:16 drh Exp $}
|
||||
|
||||
puts {<html>
|
||||
<head>
|
||||
@ -345,6 +345,118 @@ CREATE TABLE statement is synthesized and store in <b>sqlite_master</b>
|
||||
in place of the original command.
|
||||
</p>
|
||||
}
|
||||
Section {CREATE TRIGGER} createtrigger
|
||||
|
||||
Syntax {sql-statement} {
|
||||
CREATE TRIGGER <trigger-name> [ BEFORE | AFTER ]
|
||||
<database-event> ON <table-name>
|
||||
<trigger-action>
|
||||
}
|
||||
|
||||
Syntax {database-event} {
|
||||
DELETE |
|
||||
INSERT |
|
||||
UPDATE |
|
||||
UPDATE OF <column-list>
|
||||
}
|
||||
|
||||
Syntax {trigger-action} {
|
||||
[ FOR EACH ROW ] [ WHEN <expression> ]
|
||||
BEGIN
|
||||
<trigger-step> ; [ <trigger-step> ; ]*
|
||||
END
|
||||
}
|
||||
|
||||
Syntax {trigger-step} {
|
||||
<update-statement> | <insert-statement> |
|
||||
<delete-statement> | <select-statement>
|
||||
}
|
||||
|
||||
puts {
|
||||
<p>The CREATE TRIGGER statement is used to add triggers to the
|
||||
database schema. Triggers are database operations (the <i>trigger-action</i>)
|
||||
that are automatically performed when a specified database event (the
|
||||
<i>database-event</i>) occurs. </p>
|
||||
|
||||
<p>A trigger may be specified to fire whenever a DELETE, INSERT or UPDATE of a
|
||||
particular database table occurs, or whenever an UPDATE of one or more
|
||||
specified columns of a table are updated.</p>
|
||||
|
||||
<p>At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH
|
||||
STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional. FOR
|
||||
EACH ROW implies that the SQL statements specified as <i>trigger-steps</i>
|
||||
may be executed (depending on the WHEN clause) for each database row being
|
||||
inserted, updated or deleted by the statement causing the trigger to fire.</p>
|
||||
|
||||
<p>Both the WHEN clause and the <i>trigger-steps</i> may access elements of
|
||||
the row being inserted, deleted or updated using references of the form
|
||||
"NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where
|
||||
<i>column-name</i> is the name of a column from the table that the trigger
|
||||
is associated with. OLD and NEW references may only be used in triggers on
|
||||
<i>trigger-event</i>s for which they are relevant, as follows:</p>
|
||||
|
||||
<table border=0 cellpadding=10>
|
||||
<tr>
|
||||
<td valign="top" align="right" width=120><i>INSERT</i></td>
|
||||
<td valign="top">NEW references are valid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right" width=120><i>UPDATE</i></td>
|
||||
<td valign="top">NEW and OLD references are valid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right" width=120><i>DELETE</i></td>
|
||||
<td valign="top">OLD references are valid</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<p>If a WHEN clause is supplied, the SQL statements specified as <i>trigger-steps</i> are only executed for rows for which the WHEN clause is true. If no WHEN clause is supplied, the SQL statements are executed for all rows.</p>
|
||||
|
||||
<p>The specified <i>trigger-time</i> determines when the <i>trigger-steps</i>
|
||||
will be executed relative to the insertion, modification or removal of the
|
||||
associated row.</p>
|
||||
|
||||
<p>An ON CONFLICT clause may be specified as part of an UPDATE or INSERT
|
||||
<i>trigger-step</i>. However if an ON CONFLICT clause is specified as part of
|
||||
the statement causing the trigger to fire, then this conflict handling
|
||||
policy is used instead.</p>
|
||||
|
||||
<p>Triggers are automatically dropped when the table that they are
|
||||
associated with is dropped.</p>
|
||||
|
||||
<p>Triggers may be created on views, as well as ordinary tables. If one or
|
||||
more INSERT, DELETE or UPDATE triggers are defined on a view, then it is not
|
||||
an error to execute an INSERT, DELETE or UPDATE statement on the view,
|
||||
respectively. Thereafter, executing an INSERT, DELETE or UPDATE on the view
|
||||
causes the associated triggers to fire. The real tables underlying the view
|
||||
are not modified (except possibly explicitly, by a trigger program).</p>
|
||||
|
||||
<p><b>Example:</b></p>
|
||||
|
||||
<p>Assuming that customer records are stored in the "customers" table, and
|
||||
that order records are stored in the "orders" table, the following trigger
|
||||
ensures that all associated orders are redirected when a customer changes
|
||||
his or her address:</p>
|
||||
}
|
||||
Example {
|
||||
CREATE TRIGGER update_customer_address UPDATE OF address ON customers
|
||||
BEGIN
|
||||
UPDATE orders SET address = new.address WHERE customer_name = old.name;
|
||||
END;
|
||||
}
|
||||
puts {
|
||||
<p>With this trigger installed, executing the statement:</p>
|
||||
}
|
||||
Example {
|
||||
UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones';
|
||||
}
|
||||
puts {
|
||||
<p>causes the following to be automatically executed:</p>
|
||||
}
|
||||
Example {
|
||||
UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
|
||||
}
|
||||
|
||||
Section {CREATE VIEW} {createview}
|
||||
|
||||
@ -398,6 +510,15 @@ Syntax {sql-command} {
|
||||
DROP TABLE <table-name>
|
||||
}
|
||||
|
||||
Section {DROP TRIGGER} droptrigger
|
||||
Syntax {sql-statement} {
|
||||
DROP TRIGGER <trigger-name>
|
||||
}
|
||||
puts {
|
||||
<p>Used to drop a trigger from the database schema. Note that triggers
|
||||
are automatically dropped when the associated table is dropped.</p>
|
||||
}
|
||||
|
||||
puts {
|
||||
<p>The DROP TABLE statement consists of the keywords "DROP TABLE" followed
|
||||
by the name of the table. The table named is completely removed from
|
||||
@ -1091,129 +1212,6 @@ the database backend and VACUUM has become a no-op.
|
||||
</p>
|
||||
}
|
||||
|
||||
Section {CREATE TRIGGER} createtrigger
|
||||
|
||||
Syntax {sql-statement} {
|
||||
CREATE TRIGGER <trigger-name> [ BEFORE | AFTER ]
|
||||
<database-event>
|
||||
<trigger-action>
|
||||
}
|
||||
|
||||
Syntax {database-event} {
|
||||
DELETE |
|
||||
INSERT |
|
||||
UPDATE |
|
||||
UPDATE OF <column-list>
|
||||
ON <table-name>
|
||||
}
|
||||
|
||||
Syntax {trigger-action} {
|
||||
[ FOR EACH ROW ] [ WHEN <expression> ]
|
||||
BEGIN
|
||||
<trigger-step> ; [ <trigger-step> ; ]*
|
||||
END
|
||||
}
|
||||
|
||||
Syntax {trigger-step} {
|
||||
<update-statement> | <insert-statement> |
|
||||
<delete-statement> | <select-statement>
|
||||
}
|
||||
|
||||
puts {
|
||||
<p>The CREATE TRIGGER statement is used to add triggers to the
|
||||
database schema. Triggers are database operations (the <i>trigger-action</i>)
|
||||
that are automatically performed when a specified database event (the
|
||||
<i>database-event</i>) occurs. </p>
|
||||
|
||||
<p>A trigger may be specified to fire whenever a DELETE, INSERT or UPDATE of a
|
||||
particular database table occurs, or whenever an UPDATE of one or more
|
||||
specified columns of a table are updated.</p>
|
||||
|
||||
<p>At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH
|
||||
STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional. FOR
|
||||
EACH ROW implies that the SQL statements specified as <i>trigger-steps</i>
|
||||
may be executed (depending on the WHEN clause) for each database row being
|
||||
inserted, updated or deleted by the statement causing the trigger to fire.</p>
|
||||
|
||||
<p>Both the WHEN clause and the <i>trigger-steps</i> may access elements of
|
||||
the row being inserted, deleted or updated using references of the form
|
||||
"NEW.<i>column-name</i>" and "OLD.<i>column-name</i>", where
|
||||
<i>column-name</i> is the name of a column from the table that the trigger
|
||||
is associated with. OLD and NEW references may only be used in triggers on
|
||||
<i>trigger-event</i>s for which they are relevant, as follows:</p>
|
||||
|
||||
<table border=0 cellpadding=10>
|
||||
<tr>
|
||||
<td valign="top" align="right" width=120><i>INSERT</i></td>
|
||||
<td valign="top">NEW references are valid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right" width=120><i>UPDATE</i></td>
|
||||
<td valign="top">NEW and OLD references are valid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right" width=120><i>DELETE</i></td>
|
||||
<td valign="top">OLD references are valid</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<p>If a WHEN clause is supplied, the SQL statements specified as <i>trigger-steps</i> are only executed for rows for which the WHEN clause is true. If no WHEN clause is supplied, the SQL statements are executed for all rows.</p>
|
||||
|
||||
<p>The specified <i>trigger-time</i> determines when the <i>trigger-steps</i>
|
||||
will be executed relative to the insertion, modification or removal of the
|
||||
associated row.</p>
|
||||
|
||||
<p>An ON CONFLICT clause may be specified as part of an UPDATE or INSERT
|
||||
<i>trigger-step</i>. However if an ON CONFLICT clause is specified as part of
|
||||
the statement causing the trigger to fire, then this conflict handling
|
||||
policy is used instead.</p>
|
||||
|
||||
<p>Triggers are automatically dropped when the table that they are
|
||||
associated with is dropped.</p>
|
||||
|
||||
<p>Triggers may be created on views, as well as ordinary tables. If one or
|
||||
more INSERT, DELETE or UPDATE triggers are defined on a view, then it is not
|
||||
an error to execute an INSERT, DELETE or UPDATE statement on the view,
|
||||
respectively. Thereafter, executing an INSERT, DELETE or UPDATE on the view
|
||||
causes the associated triggers to fire. The real tables underlying the view
|
||||
are not modified (except possibly explicitly, by a trigger program).</p>
|
||||
|
||||
<p><b>Example:</b></p>
|
||||
|
||||
<p>Assuming that customer records are stored in the "customers" table, and
|
||||
that order records are stored in the "orders" table, the following trigger
|
||||
ensures that all associated orders are redirected when a customer changes
|
||||
his or her address:</p>
|
||||
}
|
||||
Example {
|
||||
CREATE TRIGGER update_customer_address UPDATE OF address ON customers
|
||||
BEGIN
|
||||
UPDATE orders SET address = new.address WHERE customer_name = old.name;
|
||||
END;
|
||||
}
|
||||
puts {
|
||||
<p>With this trigger installed, executing the statement:</p>
|
||||
}
|
||||
Example {
|
||||
UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones';
|
||||
}
|
||||
puts {
|
||||
<p>causes the following to be automatically executed:</p>
|
||||
}
|
||||
Example {
|
||||
UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
|
||||
}
|
||||
|
||||
Section {DROP TRIGGER} droptrigger
|
||||
Syntax {sql-statement} {
|
||||
DROP TRIGGER <trigger-name>
|
||||
}
|
||||
puts {
|
||||
<p>Used to drop a trigger from the database schema. Note that triggers
|
||||
are automatically dropped when the associated table is dropped.</p>
|
||||
}
|
||||
|
||||
|
||||
puts {
|
||||
<p><hr /></p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user