File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\command\ddl\DropAggregate.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.Session;
13 import org.h2.engine.UserAggregate;
14 import org.h2.message.DbException;
15
16 /**
17 * This class represents the statement
18 * DROP AGGREGATE
19 */
20 public class DropAggregate extends DefineCommand {
21
22 private String name;
23 private boolean ifExists;
24
25 public DropAggregate(Session session) {
26 super(session);
27 }
28
29 public int update() {
30 session.getUser().checkAdmin();
31 session.commit(true);
32 Database db = session.getDatabase();
33 UserAggregate aggregate = db.findAggregate(name);
34 if (aggregate == null) {
35 if (!ifExists) {
36 throw DbException.get(ErrorCode.AGGREGATE_NOT_FOUND_1, name);
37 }
38 } else {
39 db.removeDatabaseObject(session, aggregate);
40 }
41 return 0;
42 }
43
44 public void setName(String name) {
45 this.name = name;
46 }
47
48 public void setIfExists(boolean ifExists) {
49 this.ifExists = ifExists;
50 }
51
52 public int getType() {
53 return CommandInterface.DROP_AGGREGATE;
54 }
55
56 }
57