01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.execute.StatementTriggerExecutor
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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: * Constructor
39: *
40: * @param tec the execution context
41: * @param triggerd the trigger descriptor
42: * @param activation the activation
43: * @param lcc the lcc
44: */
45: StatementTriggerExecutor(InternalTriggerExecutionContext tec,
46: TriggerDescriptor triggerd, Activation activation,
47: LanguageConnectionContext lcc) {
48: super (tec, triggerd, activation, lcc);
49: }
50:
51: /**
52: * Fire the trigger based on the event.
53: *
54: * @param event the trigger event
55: * @param brs the before result set
56: * @param ars the after result set
57: *
58: * @exception StandardException on error or general trigger
59: * exception
60: */
61: void fireTrigger(TriggerEvent event, CursorResultSet brs,
62: CursorResultSet ars) throws StandardException {
63: tec.setTrigger(triggerd);
64: tec.setBeforeResultSet(brs);
65: tec.setAfterResultSet(ars);
66:
67: try {
68: executeSPS(getAction());
69: } finally {
70: clearSPS();
71: tec.clearTrigger();
72: }
73: }
74: }
|