db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chaa...@apache.org
Subject svn commit: r1538640 - in /db/derby/docs/trunk/src: devguide/ ref/
Date Mon, 04 Nov 2013 15:05:26 GMT
Author: chaase3
Date: Mon Nov  4 15:05:26 2013
New Revision: 1538640

URL: http://svn.apache.org/r1538640
Log:
DERBY-6390  Document the WHEN clause in the CREATE TRIGGER statement

Added a Reference Manual topic and modified 4 others and the map; modified 5 
Developer's Guide topics.

Patch: DERBY-6390-2.diff

Added:
    db/derby/docs/trunk/src/ref/rrefsqljwhenclause.dita   (with props)
Modified:
    db/derby/docs/trunk/src/devguide/cdevspecial13670.dita
    db/derby/docs/trunk/src/devguide/cdevspecial27163.dita
    db/derby/docs/trunk/src/devguide/cdevspecial53165.dita
    db/derby/docs/trunk/src/devguide/cdevspecial67260.dita
    db/derby/docs/trunk/src/devguide/cdevspecial76763.dita
    db/derby/docs/trunk/src/ref/refderby.ditamap
    db/derby/docs/trunk/src/ref/rrefdeclaretemptable.dita
    db/derby/docs/trunk/src/ref/rrefsistabs79888.dita
    db/derby/docs/trunk/src/ref/rrefsqlj37836.dita
    db/derby/docs/trunk/src/ref/rrefsqlj43125.dita

Modified: db/derby/docs/trunk/src/devguide/cdevspecial13670.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/cdevspecial13670.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/devguide/cdevspecial13670.dita (original)
+++ db/derby/docs/trunk/src/devguide/cdevspecial13670.dita Mon Nov  4 15:05:26 2013
@@ -20,24 +20,46 @@ limitations under the License.
 -->
 <reference id="cdevspecial13670" xml:lang="en-us">
 <title>Examples of trigger actions</title>
+<shortdesc>This section provides some examples of triggers.</shortdesc>
 <prolog><metadata>
 <keywords><indexterm>Triggers<indexterm>example of trigger actions</indexterm></indexterm>
 </keywords>
 </metadata></prolog>
 <refbody>
-<section><p>The following trigger action copies a row from the <i>flights</i>
table
-into the <i>flight_history</i> table whenever any row gets inserted into <i>flights</i>
and
-adds the comment "inserted from trig1" in the <i>status</i> column of
-the <i>flight_history</i> table.</p></section>
-<example> <codeblock><b>CREATE TRIGGER trig1 
-AFTER UPDATE ON flights 
-REFERENCING OLD AS UPDATEDROW 
-FOR EACH ROW MODE DB2SQL 
-INSERT INTO flights_history 
-VALUES (UPDATEDROW.FLIGHT_ID, UPDATEDROW.SEGMENT_NUMBER,
-UPDATEDROW.ORIG_AIRPORT, UPDATEDROW.DEPART_TIME,
-UPDATED ROW.DEST_AIRPORT, UPDATEDROW.ARRIVE_TIME,
-UPDATEDROW.MEAL, UPDATEDROW.FLYING_TIME, UPDATEDROW.MILES,
-UPDATEDROW.AIRCRAFT,'INSERTED FROM trig1');</b></codeblock></example>
+<section><p>The following trigger action copies a row from the
+<codeph>flights</codeph> table into the <codeph>flight_history</codeph>
table
+whenever any row gets inserted into <codeph>flights</codeph> and adds the
+comment "inserted from trig1" in the <codeph>status</codeph> column of the
+<codeph>flight_history</codeph> table.</p></section>
+<example>
+<codeblock><b>CREATE TRIGGER trig1 
+  AFTER UPDATE ON flights 
+  REFERENCING OLD AS UPDATEDROW 
+  FOR EACH ROW
+  INSERT INTO flights_history 
+    VALUES (UPDATEDROW.FLIGHT_ID, UPDATEDROW.SEGMENT_NUMBER,
+            UPDATEDROW.ORIG_AIRPORT, UPDATEDROW.DEPART_TIME,
+            UPDATED ROW.DEST_AIRPORT, UPDATEDROW.ARRIVE_TIME,
+            UPDATEDROW.MEAL, UPDATEDROW.FLYING_TIME, UPDATEDROW.MILES,
+            UPDATEDROW.AIRCRAFT,'inserted from trig1');</b></codeblock>
+</example>
+<section>
+<p>The following trigger action updates the <codeph>FlightAvailability</codeph>
+table after an update of the <codeph>flights</codeph> table by setting the
+<codeph>flight_id</codeph> column to the value of the <codeph>flight_id</codeph>
+column in the modified row. The update of the
+<codeph>FlightAvailability</codeph> table happens only if the triggering update
+actually changed the value of FLIGHTS.FLIGHT_ID.</p>
+</section>
+<example>
+<codeblock><b>CREATE TRIGGER FLIGHTSUPDATE
+  AFTER UPDATE ON flights
+  REFERENCING OLD AS OLD NEW AS NEW
+  FOR EACH ROW
+  WHEN (OLD.FLIGHT_ID &lt;&gt; NEW.FLIGHT_ID)
+  UPDATE FlightAvailability
+    SET FLIGHT_ID = NEW.FLIGHT_ID
+    WHERE FLIGHT_ID = OLD.FLIGHT_ID;</b></codeblock>
+</example>
 </refbody>
 </reference>

Modified: db/derby/docs/trunk/src/devguide/cdevspecial27163.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/cdevspecial27163.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/devguide/cdevspecial27163.dita (original)
+++ db/derby/docs/trunk/src/devguide/cdevspecial27163.dita Mon Nov  4 15:05:26 2013
@@ -32,11 +32,12 @@ table. A <i>database event</i> is a dele
 <p>For example, if you define a trigger for a delete on a particular table,
 the trigger action is executed whenever someone deletes a row or rows from
 the table.</p>
-<p>The <codeph>CREATE TRIGGER</codeph> statement in the <cite><ph
conref="../conrefs.dita#pub/citref"></ph></cite> goes
-into detail of the complete <codeph>CREATE TRIGGER</codeph> syntax. This section
-provides information on defining the trigger action itself, which is only
-one aspect of creating triggers.</p>
-<p>This section refers to the <codeph>CREATE TRIGGER</codeph> statement
as
-the <i>trigger actions</i>.</p>
+<p>The "CREATE TRIGGER statement" topic in the
+<ph conref="../conrefs.dita#pub/citref"></ph> shows the complete
+<codeph>CREATE TRIGGER</codeph> syntax. This section provides information on
+defining the trigger action itself, which is only one aspect of creating
+triggers.</p>
+<p>This section refers to the actions defined by the
+<codeph>CREATE TRIGGER</codeph> statement as the <i>trigger actions</i>.</p>
 </conbody>
 </concept>

Modified: db/derby/docs/trunk/src/devguide/cdevspecial53165.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/cdevspecial53165.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/devguide/cdevspecial53165.dita (original)
+++ db/derby/docs/trunk/src/devguide/cdevspecial53165.dita Mon Nov  4 15:05:26 2013
@@ -33,10 +33,15 @@ DELETE FROM FlightAvailability 
   WHERE flight_id IN (SELECT flight_id FROM FlightAvailability 
     WHERE YEAR(flight_date) &lt; 2005);</b>
 </codeblock>
-<p>A trigger action does have some limitations, though; for example, it cannot
-contain dynamic parameters or alter the table on which the trigger is defined.
-See the "Triggered-SQL-statement" section of the "CREATE TRIGGER statement"
-topic in the <cite><ph conref="../conrefs.dita#pub/citref"></ph></cite>
for
-details. </p>
+<p>The trigger action includes not only the
+<i><codeph>triggeredSQLStatement</codeph></i> described in the
+"triggeredSQLStatement" section of the "CREATE TRIGGER statement" topic in the
+<ph conref="../conrefs.dita#pub/citref"></ph>, but also the
+<codeph>[ FOR EACH { ROW | STATEMENT } ]</codeph> clause and the
+<codeph>WHEN</codeph> clause.</p>
+<p>A trigger action has limitations; for example, it cannot contain dynamic
+parameters or alter the table on which the trigger is defined. These limitations
+are detailed in the "triggeredSQLStatement" section of the "CREATE TRIGGER
+statement" topic in the <ph conref="../conrefs.dita#pub/citref"></ph>.</p>
 </conbody>
 </concept>

Modified: db/derby/docs/trunk/src/devguide/cdevspecial67260.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/cdevspecial67260.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/devguide/cdevspecial67260.dita (original)
+++ db/derby/docs/trunk/src/devguide/cdevspecial67260.dita Mon Nov  4 15:05:26 2013
@@ -29,14 +29,15 @@ changed.</shortdesc>
 <conbody>
 <p>Such trigger actions need to know one or both of the following:</p>
 <ul>
-<li>the "before" values of the rows being changed (their values before the
+<li>The "before" values of the rows being changed (their values before the
 database event that caused the trigger to fire)</li>
-<li>the "after" values of the rows being changed (the values to which the
+<li>The "after" values of the rows being changed (the values to which the
 database event is setting them)</li>
 </ul>
 <p><ph conref="../conrefs.dita#prod/productshortname"></ph> provides transition
 variables and transition tables for a trigger action to access these values.
-See "Referencing Old and New Values: The Referencing Clause" in the <cite><ph
-conref="../conrefs.dita#pub/citref"></ph></cite>.</p>
+See "Referencing old and new values: the REFERENCING clause" under the "CREATE
+TRIGGER statement" topic in the
+<ph conref="../conrefs.dita#pub/citref"></ph>.</p>
 </conbody>
 </concept>

Modified: db/derby/docs/trunk/src/devguide/cdevspecial76763.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/cdevspecial76763.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/devguide/cdevspecial76763.dita (original)
+++ db/derby/docs/trunk/src/devguide/cdevspecial76763.dita Mon Nov  4 15:05:26 2013
@@ -30,8 +30,9 @@ to write triggers.</shortdesc>
 </keywords>
 </metadata></prolog>
 <conbody>
-<p>You can choose to use standard SQL referential integrity to obtain this
-functionality, rather than writing triggers. See the <cite><ph conref="../conrefs.dita#pub/citref"></ph></cite>
for
-more information on referential integrity.</p>
+<p>You can choose to use standard SQL referential integrity (using foreign keys)
+to obtain this functionality, rather than writing triggers. See the "CONSTRAINT
+clause" topic in the <ph conref="../conrefs.dita#pub/citref"></ph> for
+details.</p>
 </conbody>
 </concept>

Modified: db/derby/docs/trunk/src/ref/refderby.ditamap
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/refderby.ditamap?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/refderby.ditamap (original)
+++ db/derby/docs/trunk/src/ref/refderby.ditamap Mon Nov  4 15:05:26 2013
@@ -638,8 +638,8 @@ limitations under the License.
 </topicref>
 </topicref>
 <topicref collection-type="family" href="rrefsqlj43125.dita" navtitle="CREATE TRIGGER
statement">
-<topicref href="rrefsqlj89752.dita" navtitle="referencingClause">
-</topicref>
+<topicref href="rrefsqlj89752.dita" navtitle="referencingClause"/>
+<topicref href="rrefsqljwhenclause.dita" navtitle="WHEN clause"/>
 </topicref>
 <topicref href="rrefsqljcreatetype.dita" navtitle="CREATE TYPE statement">
 </topicref>

Modified: db/derby/docs/trunk/src/ref/rrefdeclaretemptable.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefdeclaretemptable.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefdeclaretemptable.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefdeclaretemptable.dita Mon Nov  4 15:05:26 2013
@@ -131,7 +131,7 @@ are not supported by <ph conref="../conr
 <li>PARTITIONING KEY</li>
 <li>WITH REPLACE </li>
 </ul> </p></section>
-<section><title>Restrictions on Declared Global Temporary Tables</title>
<p><ph
+<section><title>Restrictions on declared global temporary tables</title>
<p><ph
 conref="../conrefs.dita#prod/productshortname"></ph> does not support the
 following features on temporary tables. Some of these features are specific
 to temporary tables and some are specific to <ph conref="../conrefs.dita#prod/productshortname"></ph>.</p><p>Temporary
@@ -151,7 +151,8 @@ tables and temporary tables) </li>
 <li>Caching statements that reference SESSION schema tables and views</li>
 <li>Temporary tables cannot be specified in referential constraints and primary
 keys</li>
-<li>Temporary tables cannot be referenced in a triggered-SQL-statement</li>
+<li>Temporary tables cannot be referenced in a <i>triggeredSQLStatement</i>
or
+in a WHEN clause</li>
 <li>Check constraints on columns</li>
 <li>Generated-column-spec</li>
 <li>Importing into temporary tables</li>

Modified: db/derby/docs/trunk/src/ref/rrefsistabs79888.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsistabs79888.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsistabs79888.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsistabs79888.dita Mon Nov  4 15:05:26 2013
@@ -116,15 +116,15 @@ insert</entry>
 <entry colname="2">CHAR</entry>
 <entry colname="3">36</entry>
 <entry colname="4">true</entry>
-<entry colname="5">Used only if there is a WHEN clause (not yet supported)</entry>
+<entry colname="5">ID of the trigger's WHEN clause, if one is present</entry>
 </row>
 <row>
 <entry colname="1">ACTIONSTMTID</entry>
 <entry colname="2">CHAR</entry>
 <entry colname="3">36</entry>
 <entry colname="4">true</entry>
-<entry colname="5">ID of the stored prepared statement for the triggered-SQL-statement
-(join with SYSSTATEMENTS.STMTID)</entry>
+<entry colname="5">ID of the stored prepared statement for the
+<i>triggeredSQLStatement</i> (join with SYSSTATEMENTS.STMTID)</entry>
 </row>
 <row>
 <entry colname="1">REFERENCEDCOLUMNS</entry>
@@ -174,11 +174,18 @@ to the NEW row or table</entry>
 <entry colname="4">true</entry>
 <entry colname="5">Pseudoname as set using the REFERENCING NEW AS clause </entry>
 </row>
+<row>
+<entry colname="1">WHENCLAUSETEXT</entry>
+<entry colname="2">LONG VARCHAR</entry>
+<entry colname="3">32,700</entry>
+<entry colname="4">true</entry>
+<entry colname="5">Text of the trigger's WHEN clause, if one is present</entry>
+</row>
 </tbody>
 </tgroup>
 </table></section>
-<section><p>Any SQL text that is part of a triggered-SQL-statement is compiled
-and stored in the SYSSTATEMENTS table. ACTIONSTMTID and WHENSTMTID are
+<section><p>Any SQL text that is part of a <i>triggeredSQLStatement</i>
is
+compiled and stored in the SYSSTATEMENTS table. ACTIONSTMTID and WHENSTMTID are
 foreign keys that reference SYSSTATEMENTS.STMTID. The statements for
 a trigger are always in the same schema as the trigger.</p></section>
 </refbody>

Modified: db/derby/docs/trunk/src/ref/rrefsqlj37836.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqlj37836.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqlj37836.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqlj37836.dita Mon Nov  4 15:05:26 2013
@@ -144,11 +144,13 @@ identity column. <ph conref="../conrefs.
 this way to avoid locking a row in SYS.SYSCOLUMNS for the duration
 of a transaction and keeping concurrency high. </p><p><indexterm>Identity
 columns <indexterm>and triggers</indexterm></indexterm>When an insert happens
-within a triggered-SQL-statement, the value inserted by the triggered-SQL-statement
+within a <i>triggeredSQLStatement</i>, the value inserted by the
+<i>triggeredSQLStatement</i>
 into the identity column is available from <i>ConnectionInfo</i> only within
 the trigger code. The trigger code is also able to see the value inserted
 by the statement that caused the trigger to fire. However, the statement that
-caused the trigger to fire is not able to see the value inserted by the triggered-SQL-statement
+caused the trigger to fire is not able to see the value inserted by the
+<i>triggeredSQLStatement</i>
 into the identity column. Likewise, triggers can be nested (or recursive).
 An SQL statement can cause trigger T1 to fire. T1 in turn executes an SQL
 statement that causes trigger T2 to fire. If both T1 and T2 insert rows into

Modified: db/derby/docs/trunk/src/ref/rrefsqlj43125.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqlj43125.dita?rev=1538640&r1=1538639&r2=1538640&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqlj43125.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqlj43125.dita Mon Nov  4 15:05:26 2013
@@ -62,6 +62,7 @@ href="rrefcolumnname.dita#rrefcolumnname
 ON <i><xref href="rreftablename.dita#rreftablename">tableName</xref></i>
 [ <i><xref href="rrefsqlj89752.dita#rrefsqlj89752">referencingClause</xref></i>
]
 [ FOR EACH { ROW | STATEMENT } ] [ MODE DB2SQL ] 
+[ <xref href="rrefsqljwhenclause.dita#rrefsqljwhenclause">WHEN ( <i>booleanExpression</i>
)</xref> ]
 <i><xref href="rrefsqlj43125.dita#rrefsqlj43125/i1149821">triggeredSQLStatement</xref></i></b></codeblock>
</refsyn>
 <section><title>Before or after: when triggers fire</title> <p>Triggers
are
 defined as either <i>Before</i> or <i>After</i> triggers. <ul>
@@ -81,7 +82,7 @@ you define it (see <xref href="rrefsqlj4
 <li>DELETE</li>
 </ul></p> <p>You can define any number of triggers for a given event on
a
 given table. For update, you can specify columns.</p> </section>
-<section id="sqlj67748"><title>Referencing old and new values: the referencing
+<section id="sqlj67748"><title>Referencing old and new values: the REFERENCING
 clause</title> <p>Many <i>triggeredSQLStatement</i>s need to refer
to data that
 is currently being changed by the database event that caused them to fire.
 The <i>triggeredSQLStatement</i> might need to refer to the new (post-change
or
@@ -89,7 +90,7 @@ The <i>triggeredSQLStatement</i> might n
 you with a number of ways to refer to data that is currently being changed
 by the database event that caused the trigger to fire. Changed data can be
 referred to in the <i>triggeredSQLStatement</i> using <i>transition variables</i>
or <i>transition
-tables</i>. The referencing clause allows you to provide a correlation name
+tables</i>. The REFERENCING clause allows you to provide a correlation name
 or alias for these transition variables by specifying OLD/NEW AS <i>correlationName
</i>.</p> <p>For
 example, if you add the following clause to the trigger definition:   <codeblock><b>REFERENCING
OLD AS DELETEDROW</b></codeblock></p> <p>you
 can then refer to this correlation name in the <i>triggeredSQLStatement</i>:
  <codeblock><b>DELETE FROM HotelAvailability WHERE hotel_id = DELETEDROW.hotel_id</b
@@ -98,7 +99,7 @@ a single row.   <note>Only row triggers 
 can use the transition variables. INSERT row triggers cannot reference an
 OLD row. DELETE row triggers cannot reference a NEW row.</note></p> <p>For
 statement triggers, transition <i>tables</i> serve as a table identifier for
-the <i>triggeredSQLStatement</i> or the trigger qualification. The referencing
+the <i>triggeredSQLStatement</i> or the trigger qualification. The REFERENCING
 clause allows you to provide a correlation name or alias for these transition
 tables by specifying OLD_TABLE/NEW_TABLE AS correlationName</p> <p>For example:
   <codeblock><b>REFERENCING OLD_TABLE AS DeletedHotels</b></codeblock></p>
<p>allows
@@ -110,10 +111,13 @@ equivalent to the number of rows affecte
 statement triggers (see <xref href="rrefsqlj43125.dita#rrefsqlj43125/sqlj54276"></xref>)
 can use the transition tables. INSERT statement triggers cannot reference
 an OLD table. DELETE statement triggers cannot reference a NEW table.</note></p>
<p>The
-referencing clause can designate only one new correlation or identifier and
+REFERENCING clause can designate only one new correlation or identifier and
 only one old correlation or identifier. Row triggers cannot designate an identifier
 for a transition table and statement triggers cannot designate a correlation
-for transition variables.  </p> </section>
+for transition variables.</p>
+<p>The transition tables or transition variables defined in the REFERENCING
+clause can be referenced from the WHEN clause.</p>
+</section>
 <section id="sqlj54276"><title>Statement versus row triggers</title> <p>You
 have the option to specify whether a trigger is a <i>statement trigger</i> or
a <i>row trigger</i>.
 If it is not specified in the CREATE TRIGGER statement via FOR EACH clause, then the trigger
is  
@@ -140,17 +144,18 @@ the trigger is defined.</li>
 the trigger is defined.</li>
 <li>It must not commit or roll back the current transaction or change the
 isolation level.</li>
+<li>It must not reference a table in the SESSION schema (such as a temporary
+table; see
+<xref href="rrefdeclaretemptable.dita#rrefdeclaretemptable"/>).</li>
 <li>Before triggers cannot have INSERT, UPDATE or DELETE statements as their
 action.</li>
 <li>Before triggers cannot call procedures that modify SQL data as their action.</li>
 <li>The NEW variable of a Before trigger cannot reference a generated column.
 </li>
-</ul></p><p>The <i>triggeredSQLStatement</i> can reference
database objects other
-than the table upon which the trigger is declared. If any of these database
-objects is dropped, the trigger is invalidated. If the trigger cannot be successfully
-recompiled upon the next execution, the invocation throws an exception and
-the statement that caused it to fire will be rolled back.</p><p>For more information
-on <i>triggeredSQLStatement</i>s, see the <cite><ph conref="../conrefs.dita#pub/citdevelop"></ph></cite>.</p>
</section>
+</ul></p>
+<p>For more information on <i>triggeredSQLStatement</i>s, see "Programming
+trigger actions" in the <ph conref="../conrefs.dita#pub/citdevelop"></ph>.</p>
+</section>
 <section><title>Order of execution</title> <p>When a database event
occurs
 that fires a trigger, <ph conref="../conrefs.dita#prod/productshortname"></ph>
performs
 actions in this order:   <ul>

Added: db/derby/docs/trunk/src/ref/rrefsqljwhenclause.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljwhenclause.dita?rev=1538640&view=auto
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljwhenclause.dita (added)
+++ db/derby/docs/trunk/src/ref/rrefsqljwhenclause.dita Mon Nov  4 15:05:26 2013
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN"
+ "../dtd/reference.dtd">
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at      
+
+http://www.apache.org/licenses/LICENSE-2.0  
+
+Unless required by applicable law or agreed to in writing, software  
+distributed under the License is distributed on an "AS IS" BASIS,  
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
+See the License for the specific language governing permissions and  
+limitations under the License.
+-->
+<reference id="rrefsqljwhenclause" xml:lang="en-us">
+<title>WHEN clause</title>
+<prolog><metadata>
+<keywords><indexterm>CREATE TRIGGER statement<indexterm>WHEN clause</indexterm></indexterm>
+<indexterm>triggers<indexterm>WHEN clause</indexterm></indexterm>
+<indexterm>WHEN clause<indexterm>CREATE TRIGGER statement</indexterm></indexterm>
+</keywords>
+</metadata></prolog>
+<refbody>
+<section><p>The WHEN clause is an optional part of a
+<xref href="rrefsqlj43125.dita#rrefsqlj43125">CREATE TRIGGER statement</xref>.</p>
+</section>
+<refsyn><title>Syntax</title>
+<codeblock><b>WHEN ( <i><xref
+href="rrefsqlj23075.dita#rrefsqlj23075">booleanExpression</xref></i> )</b></codeblock>
+</refsyn>
+<section>
+<p>If a trigger has been created with a WHEN clause, and the trigger event takes
+place, the <i><xref
+href="rrefsqlj43125.dita#rrefsqlj43125/i1149821">triggeredSQLStatement</xref></i>
+will be executed only if the <i>booleanExpression</i> in the WHEN clause
+evaluates to TRUE. If it evaluates to FALSE or NULL, the
+<i>triggeredSQLStatement</i> will not be executed.</p>
+<p>The transition tables or transition variables defined in the REFERENCING
+clause can be referenced from the WHEN clause.</p>
+<p>The restrictions listed for the <i>triggeredSQLStatement</i>
+in the CREATE TRIGGER statement also apply to the WHEN clause.</p>
+</section>
+<example><title>Example</title>
+<codeblock><b>CREATE TRIGGER FLIGHTSUPDATE
+    AFTER UPDATE ON FLIGHTS
+    REFERENCING OLD AS OLD NEW AS NEW
+    FOR EACH ROW
+    WHEN (OLD.FLIGHT_ID &lt;&gt; NEW.FLIGHT_ID)
+    UPDATE FLIGHTAVAILABILITY
+        SET FLIGHT_ID = NEW.FLIGHT_ID
+        WHERE FLIGHT_ID = OLD.FLIGHT_ID</b></codeblock>
+</example>
+</refbody>
+</reference>

Propchange: db/derby/docs/trunk/src/ref/rrefsqljwhenclause.dita
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message