KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > StatementTriggerExecutor


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.StatementTriggerExecutor
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute;
23
24 import org.apache.derby.iapi.sql.execute.CursorResultSet;
25 import org.apache.derby.iapi.sql.dictionary.TriggerDescriptor;
26 import org.apache.derby.iapi.error.StandardException;
27 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
28
29 import org.apache.derby.iapi.sql.Activation;
30
31 /**
32  * A statement trigger executor is an object that executes
33  * a statement trigger. It is instantiated at execution
34  * time. There is one per statement trigger.
35  */

36 public class StatementTriggerExecutor extends GenericTriggerExecutor
37 {
38     /**
39      * Constructor
40      *
41      * @param tec the execution context
42      * @param triggerd the trigger descriptor
43      * @param activation the activation
44      * @param lcc the lcc
45      */

46     StatementTriggerExecutor
47     (
48         InternalTriggerExecutionContext tec,
49         TriggerDescriptor triggerd,
50         Activation activation,
51         LanguageConnectionContext lcc
52     )
53     {
54         super(tec, triggerd, activation, lcc);
55     }
56
57     /**
58      * Fire the trigger based on the event.
59      *
60      * @param event the trigger event
61      * @param brs the before result set
62      * @param ars the after result set
63      *
64      * @exception StandardException on error or general trigger
65      * exception
66      */

67     void fireTrigger
68     (
69         TriggerEvent event,
70         CursorResultSet brs,
71         CursorResultSet ars
72     ) throws StandardException
73     {
74         tec.setTrigger(triggerd);
75         tec.setBeforeResultSet(brs);
76         tec.setAfterResultSet(ars);
77         
78         try
79         {
80             executeSPS(getAction());
81         }
82         finally
83         {
84             clearSPS();
85             tec.clearTrigger();
86         }
87     }
88 }
89
Popular Tags