KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > compile > DropTriggerNode


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.DropTriggerNode
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.compile;
23
24 import org.apache.derby.iapi.sql.compile.CompilerContext;
25 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
26 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
27 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
28 import org.apache.derby.iapi.sql.dictionary.TriggerDescriptor;
29 import org.apache.derby.iapi.reference.SQLState;
30 import org.apache.derby.iapi.sql.execute.ConstantAction;
31 import org.apache.derby.iapi.error.StandardException;
32 import org.apache.derby.iapi.services.context.ContextManager;
33 import org.apache.derby.iapi.services.sanity.SanityManager;
34
35 /**
36  * A DropTriggerNode is the root of a QueryTree that represents a DROP TRIGGER
37  * statement.
38  *
39  * @author Jamie
40  */

41 public class DropTriggerNode extends DDLStatementNode
42 {
43     private TableDescriptor td;
44
45     public String JavaDoc statementToString()
46     {
47         return "DROP TRIGGER";
48     }
49
50     /**
51      * Bind this DropTriggerNode. This means looking up the trigger,
52      * verifying it exists and getting its table uuid.
53      *
54      * @return The bound query tree
55      *
56      * @exception StandardException Thrown on error
57      */

58     public QueryTreeNode bind() throws StandardException
59     {
60         CompilerContext cc = getCompilerContext();
61         DataDictionary dd = getDataDictionary();
62
63         SchemaDescriptor sd = getSchemaDescriptor();
64
65         TriggerDescriptor triggerDescriptor = null;
66         
67         if (sd.getUUID() != null)
68             triggerDescriptor = dd.getTriggerDescriptor(getRelativeName(), sd);
69
70         if (triggerDescriptor == null)
71         {
72             throw StandardException.newException(SQLState.LANG_OBJECT_NOT_FOUND, "TRIGGER", getFullName());
73         }
74
75         /* Get the table descriptor */
76         td = triggerDescriptor.getTableDescriptor();
77         cc.createDependency(td);
78         cc.createDependency(triggerDescriptor);
79             
80         return this;
81     }
82
83     // inherit generate() method from DDLStatementNode
84

85     /**
86      * Create the Constant information that will drive the guts of Execution.
87      *
88      * @exception StandardException Thrown on failure
89      */

90     public ConstantAction makeConstantAction() throws StandardException
91     {
92         return getGenericConstantActionFactory().getDropTriggerConstantAction(
93                                             getSchemaDescriptor(),
94                                             getRelativeName(),
95                                             td.getUUID());
96     }
97 }
98
Popular Tags