use of org.h2.command.Command in project h2database by h2database.
the class Parser method parseCreateSequence.
private CreateSequence parseCreateSequence() {
boolean ifNotExists = readIfNotExists();
String sequenceName = readIdentifierWithSchema();
CreateSequence command = new CreateSequence(session, getSchema());
command.setIfNotExists(ifNotExists);
command.setSequenceName(sequenceName);
while (true) {
if (readIf("START")) {
readIf("WITH");
command.setStartWith(readExpression());
} else if (readIf("INCREMENT")) {
readIf("BY");
command.setIncrement(readExpression());
} else if (readIf("MINVALUE")) {
command.setMinValue(readExpression());
} else if (readIf("NOMINVALUE")) {
command.setMinValue(null);
} else if (readIf("MAXVALUE")) {
command.setMaxValue(readExpression());
} else if (readIf("NOMAXVALUE")) {
command.setMaxValue(null);
} else if (readIf("CYCLE")) {
command.setCycle(true);
} else if (readIf("NOCYCLE")) {
command.setCycle(false);
} else if (readIf("NO")) {
if (readIf("MINVALUE")) {
command.setMinValue(null);
} else if (readIf("MAXVALUE")) {
command.setMaxValue(null);
} else if (readIf("CYCLE")) {
command.setCycle(false);
} else if (readIf("CACHE")) {
command.setCacheSize(ValueExpression.get(ValueLong.get(1)));
} else {
break;
}
} else if (readIf("CACHE")) {
command.setCacheSize(readExpression());
} else if (readIf("NOCACHE")) {
command.setCacheSize(ValueExpression.get(ValueLong.get(1)));
} else if (readIf("BELONGS_TO_TABLE")) {
command.setBelongsToTable(true);
} else if (readIf("ORDER")) {
// Oracle compatibility
} else {
break;
}
}
return command;
}
use of org.h2.command.Command in project h2database by h2database.
the class Parser method parseScript.
private ScriptCommand parseScript() {
ScriptCommand command = new ScriptCommand(session);
boolean data = true, passwords = true, settings = true;
boolean dropTables = false, simple = false;
if (readIf("SIMPLE")) {
simple = true;
}
if (readIf("NODATA")) {
data = false;
}
if (readIf("NOPASSWORDS")) {
passwords = false;
}
if (readIf("NOSETTINGS")) {
settings = false;
}
if (readIf("DROP")) {
dropTables = true;
}
if (readIf("BLOCKSIZE")) {
long blockSize = readLong();
command.setLobBlockSize(blockSize);
}
command.setData(data);
command.setPasswords(passwords);
command.setSettings(settings);
command.setDrop(dropTables);
command.setSimple(simple);
if (readIf("TO")) {
command.setFileNameExpr(readExpression());
if (readIf("COMPRESSION")) {
command.setCompressionAlgorithm(readUniqueIdentifier());
}
if (readIf("CIPHER")) {
command.setCipher(readUniqueIdentifier());
if (readIf("PASSWORD")) {
command.setPassword(readExpression());
}
}
if (readIf("CHARSET")) {
command.setCharset(Charset.forName(readString()));
}
}
if (readIf("SCHEMA")) {
HashSet<String> schemaNames = new HashSet<>();
do {
schemaNames.add(readUniqueIdentifier());
} while (readIf(","));
command.setSchemaNames(schemaNames);
} else if (readIf("TABLE")) {
ArrayList<Table> tables = New.arrayList();
do {
tables.add(readTableOrView());
} while (readIf(","));
command.setTables(tables);
}
return command;
}
use of org.h2.command.Command in project h2database by h2database.
the class Parser method parseDeallocate.
private DeallocateProcedure parseDeallocate() {
readIf("PLAN");
String procedureName = readAliasIdentifier();
DeallocateProcedure command = new DeallocateProcedure(session);
command.setProcedureName(procedureName);
return command;
}
use of org.h2.command.Command in project h2database by h2database.
the class Parser method parseSelectUnion.
private Query parseSelectUnion() {
int start = lastParseIndex;
Query command = parseSelectSub();
return parseSelectUnionExtension(command, start, false);
}
use of org.h2.command.Command in project h2database by h2database.
the class AlterTableAlterColumn method checkNoNullValues.
private void checkNoNullValues(Table table) {
String sql = "SELECT COUNT(*) FROM " + table.getSQL() + " WHERE " + oldColumn.getSQL() + " IS NULL";
Prepared command = session.prepare(sql);
ResultInterface result = command.query(0);
result.next();
if (result.currentRow()[0].getInt() > 0) {
throw DbException.get(ErrorCode.COLUMN_CONTAINS_NULL_VALUES_1, oldColumn.getSQL());
}
}
Aggregations