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