01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.command.ddl;
07:
08: import java.sql.SQLException;
09:
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.Message;
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() throws SQLException {
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 Message.getSQLException(
41: ErrorCode.USER_DATA_TYPE_NOT_FOUND_1, typeName);
42: }
43: } else {
44: db.removeDatabaseObject(session, type);
45: }
46: return 0;
47: }
48:
49: public void setTypeName(String name) {
50: this.typeName = name;
51: }
52:
53: }
|