KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > interpret > DropTrigger


1 /**
2  * com.mckoi.database.interpret.DropTrigger 14 Sep 2001
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database.interpret;
26
27 import com.mckoi.database.*;
28 import com.mckoi.util.IntegerVector;
29 import java.util.ArrayList JavaDoc;
30 import java.util.List JavaDoc;
31
32 /**
33  * A parsed state container for the 'DROP TRIGGER' statement.
34  *
35  * @author Tobias Downer
36  */

37
38 public class DropTrigger extends Statement {
39
40   /**
41    * The name of this trigger.
42    */

43   String JavaDoc trigger_name;
44
45
46   // ---------- Implemented from Statement ----------
47

48   public void prepare() throws DatabaseException {
49     trigger_name = (String JavaDoc) cmd.getObject("trigger_name");
50   }
51
52   public Table evaluate() throws DatabaseException {
53
54     String JavaDoc type = (String JavaDoc) cmd.getObject("type");
55
56     DatabaseQueryContext context = new DatabaseQueryContext(database);
57
58     if (type.equals("callback_trigger")) {
59       database.deleteTrigger(trigger_name);
60     }
61     else {
62
63       // Convert the trigger into a table name,
64
String JavaDoc schema_name = database.getCurrentSchema();
65       TableName t_name = TableName.resolve(schema_name, trigger_name);
66       t_name = database.tryResolveCase(t_name);
67
68       ConnectionTriggerManager manager = database.getConnectionTriggerManager();
69       manager.dropTrigger(t_name.getSchema(), t_name.getName());
70
71       // Drop the grants for this object
72
database.getGrantManager().revokeAllGrantsOnObject(
73                                     GrantManager.TABLE, t_name.toString());
74     }
75     
76     // Return '0' if we created the trigger.
77
return FunctionTable.resultTable(context, 0);
78   }
79
80
81 }
82
Popular Tags