File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\command\ddl\DropFunctionAlias.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.command.ddl;
8
9 import org.h2.command.CommandInterface;
10 import org.h2.constant.ErrorCode;
11 import org.h2.engine.Database;
12 import org.h2.engine.FunctionAlias;
13 import org.h2.engine.Session;
14 import org.h2.message.DbException;
15 import org.h2.schema.Schema;
16
17 /**
18 * This class represents the statement
19 * DROP ALIAS
20 */
21 public class DropFunctionAlias extends SchemaCommand {
22
23 private String aliasName;
24 private boolean ifExists;
25
26 public DropFunctionAlias(Session session, Schema schema) {
27 super(session, schema);
28 }
29
30 public int update() {
31 session.getUser().checkAdmin();
32 session.commit(true);
33 Database db = session.getDatabase();
34 FunctionAlias functionAlias = getSchema().findFunction(aliasName);
35 if (functionAlias == null) {
36 if (!ifExists) {
37 throw DbException.get(ErrorCode.FUNCTION_ALIAS_NOT_FOUND_1, aliasName);
38 }
39 } else {
40 db.removeSchemaObject(session, functionAlias);
41 }
42 return 0;
43 }
44
45 public void setAliasName(String name) {
46 this.aliasName = name;
47 }
48
49 public void setIfExists(boolean ifExists) {
50 this.ifExists = ifExists;
51 }
52
53 public int getType() {
54 return CommandInterface.DROP_ALIAS;
55 }
56
57 }
58