use of org.jooq.AlterSequenceStep in project jOOQ by jOOQ.
the class DefaultParseContext method parseAlterSequence.
private final DDLQuery parseAlterSequence() {
boolean ifExists = parseKeywordIf("IF EXISTS");
Sequence<?> sequenceName = parseSequenceName();
AlterSequenceStep s = ifExists ? dsl.alterSequenceIfExists(sequenceName) : dsl.alterSequence(sequenceName);
if (parseKeywordIf("RENAME")) {
parseKeyword("AS", "TO");
return s.renameTo(parseSequenceName());
} else if (parseKeywordIf("OWNER TO") && parseUser() != null) {
return IGNORE;
} else {
boolean found = false;
boolean restart = false;
boolean startWith = false;
boolean incrementBy = false;
boolean minvalue = false;
boolean maxvalue = false;
boolean cycle = false;
boolean cache = false;
AlterSequenceFlagsStep s1 = s;
while (true) {
Field<Long> field;
if (!startWith && (startWith |= (field = parseSequenceStartWithIf()) != null))
s1 = s1.startWith(field);
else if (!incrementBy && (incrementBy |= (field = parseSequenceIncrementByIf()) != null))
s1 = s1.incrementBy(field);
else if (!minvalue && (minvalue |= (field = parseSequenceMinvalueIf()) != null))
s1 = s1.minvalue(field);
else if (!minvalue && (minvalue |= parseSequenceNoMinvalueIf()))
s1 = s1.noMinvalue();
else if (!maxvalue && (maxvalue |= (field = parseSequenceMaxvalueIf()) != null))
s1 = s1.maxvalue(field);
else if (!maxvalue && (maxvalue |= parseSequenceNoMaxvalueIf()))
s1 = s1.noMaxvalue();
else if (!cycle && (cycle |= parseKeywordIf("CYCLE")))
s1 = s1.cycle();
else if (!cycle && (cycle |= parseSequenceNoCycleIf()))
s1 = s1.noCycle();
else if (!cache && (cache |= (field = parseSequenceCacheIf()) != null))
s1 = s1.cache(field);
else if (!cache && (cache |= parseSequenceNoCacheIf()))
s1 = s1.noCache();
else if (!restart && (restart |= parseKeywordIf("RESTART"))) {
if (parseKeywordIf("WITH"))
s1 = s1.restartWith(parseUnsignedIntegerOrBindVariable());
else
s1 = s1.restart();
} else
break;
found = true;
}
if (!found)
throw expected("CACHE", "CYCLE", "INCREMENT BY", "MAXVALUE", "MINVALUE", "NO CACHE", "NO CYCLE", "NO MAXVALUE", "NO MINVALUE", "OWNER TO", "RENAME TO", "RESTART", "START WITH");
return s1;
}
}
Aggregations