KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > command > ddl > DropFunctionAlias


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.command.ddl;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.engine.Database;
10 import org.h2.engine.FunctionAlias;
11 import org.h2.engine.Session;
12 import org.h2.message.Message;
13
14 public class DropFunctionAlias extends DefineCommand {
15
16     private String JavaDoc aliasName;
17     private boolean ifExists;
18     
19     public DropFunctionAlias(Session session) {
20         super(session);
21     }
22
23     public int update() throws SQLException JavaDoc {
24         session.getUser().checkAdmin();
25         session.commit();
26         Database db = session.getDatabase();
27         FunctionAlias functionAlias = db.findFunctionAlias(aliasName);
28         if(functionAlias == null) {
29             if(!ifExists) {
30                 throw Message.getSQLException(Message.FUNCTION_ALIAS_NOT_FOUND_1, aliasName);
31             }
32         } else {
33             db.removeDatabaseObject(session, functionAlias);
34         }
35         return 0;
36     }
37     
38     public void setAliasName(String JavaDoc name) {
39         this.aliasName = name;
40     }
41
42     public void setIfExists(boolean ifExists) {
43         this.ifExists = ifExists;
44     }
45
46 }
47
Popular Tags