use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project jOOQ by jOOQ.
the class FirebirdDatabase method loadForeignKeys.
@Override
protected void loadForeignKeys(DefaultRelations relations) throws SQLException {
Rdb$relationConstraints pk = RDB$RELATION_CONSTRAINTS.as("pk");
Rdb$relationConstraints fk = RDB$RELATION_CONSTRAINTS.as("fk");
Rdb$refConstraints rc = RDB$REF_CONSTRAINTS.as("rc");
Rdb$indexSegments isp = RDB$INDEX_SEGMENTS.as("isp");
Rdb$indexSegments isf = RDB$INDEX_SEGMENTS.as("isf");
for (Record record : create().selectDistinct(fk.RDB$CONSTRAINT_NAME.trim().as("fk"), fk.RDB$RELATION_NAME.trim().as("fkTable"), isf.RDB$FIELD_NAME.trim().as("fkField"), pk.RDB$CONSTRAINT_NAME.trim().as("pk"), pk.RDB$RELATION_NAME.trim().as("pkTable")).from(fk).join(rc).on(fk.RDB$CONSTRAINT_NAME.eq(rc.RDB$CONSTRAINT_NAME)).join(pk).on(pk.RDB$CONSTRAINT_NAME.eq(rc.RDB$CONST_NAME_UQ)).join(isp).on(isp.RDB$INDEX_NAME.eq(pk.RDB$INDEX_NAME)).join(isf).on(isf.RDB$INDEX_NAME.eq(fk.RDB$INDEX_NAME)).where(isp.RDB$FIELD_POSITION.eq(isf.RDB$FIELD_POSITION)).orderBy(fk.RDB$CONSTRAINT_NAME.asc(), isf.RDB$FIELD_POSITION.asc()).fetch()) {
String pkName = record.get("pk", String.class);
String pkTable = record.get("pkTable", String.class);
String fkName = record.get("fk", String.class);
String fkTable = record.get("fkTable", String.class);
String fkField = record.get("fkField", String.class);
TableDefinition tdReferencing = getTable(getSchemata().get(0), fkTable, true);
TableDefinition tdReferenced = getTable(getSchemata().get(0), pkTable, true);
if (tdReferenced != null && tdReferencing != null) {
ColumnDefinition referencingColumn = tdReferencing.getColumn(fkField);
relations.addForeignKey(fkName, pkName, referencingColumn, getSchemata().get(0));
}
}
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project jOOQ by jOOQ.
the class FirebirdRoutineDefinition method init0.
@Override
protected void init0() throws SQLException {
Rdb$procedureParameters p = RDB$PROCEDURE_PARAMETERS.as("p");
Rdb$fields f = RDB$FIELDS.as("f");
int i = 0;
for (Record record : create().select(p.RDB$PARAMETER_NUMBER, p.RDB$PARAMETER_TYPE, p.RDB$PARAMETER_NAME.trim().as(p.RDB$PARAMETER_NAME), FIELD_TYPE(f).as("FIELD_TYPE"), CHARACTER_LENGTH(f).as("CHARACTER_LENGTH"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), DSL.bitOr(p.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(p.RDB$NULL_FLAG), p.RDB$DEFAULT_SOURCE).from(p).leftOuterJoin(f).on(p.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(p.RDB$PROCEDURE_NAME.eq(getName())).orderBy(p.RDB$PARAMETER_TYPE.desc(), p.RDB$PARAMETER_NUMBER.asc())) {
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHARACTER_LENGTH", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(p.RDB$NULL_FLAG) == 0, record.get(p.RDB$DEFAULT_SOURCE));
ParameterDefinition parameter = new DefaultParameterDefinition(this, record.get(p.RDB$PARAMETER_NAME), i++, type);
addParameter(record.get(p.RDB$PARAMETER_TYPE, int.class).equals(0) ? InOutDefinition.IN : InOutDefinition.OUT, parameter);
}
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project jOOQ by jOOQ.
the class FirebirdTableDefinition method getElements0.
@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
Rdb$relationFields r = RDB$RELATION_FIELDS.as("r");
Rdb$fields f = RDB$FIELDS.as("f");
// DatabaseMetaData implementation
for (Record record : create().select(r.RDB$FIELD_NAME.trim(), r.RDB$DESCRIPTION, r.RDB$DEFAULT_VALUE, DSL.bitOr(r.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(r.RDB$NULL_FLAG), r.RDB$DEFAULT_SOURCE, r.RDB$FIELD_POSITION, // [#3342] FIELD_LENGTH should be ignored for LOBs
CHARACTER_LENGTH(f).as("CHARACTER_LENGTH"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), f.RDB$FIELD_SUB_TYPE).from(r).leftOuterJoin(f).on(r.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(r.RDB$RELATION_NAME.eq(getName())).orderBy(r.RDB$FIELD_POSITION).fetch()) {
DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHARACTER_LENGTH", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(r.RDB$NULL_FLAG) == 0, record.get(r.RDB$DEFAULT_SOURCE));
ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(r.RDB$FIELD_NAME.trim()), record.get(r.RDB$FIELD_POSITION), type, false, null);
result.add(column);
}
return result;
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project jOOQ by jOOQ.
the class FirebirdTableValuedFunction method getElements0.
@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
Rdb$procedureParameters p = RDB$PROCEDURE_PARAMETERS.as("p");
Rdb$fields f = RDB$FIELDS.as("f");
// DatabaseMetaData implementation
for (Record record : create().select(p.RDB$PARAMETER_NUMBER, p.RDB$PARAMETER_NAME.trim(), p.RDB$DESCRIPTION, p.RDB$DEFAULT_VALUE, DSL.bitOr(p.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(p.RDB$NULL_FLAG), p.RDB$DEFAULT_SOURCE, // [#3342] FIELD_LENGTH should be ignored for LOBs
CHARACTER_LENGTH(f).as("CHARACTER_LENGTH"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), f.RDB$FIELD_SUB_TYPE).from(p).leftOuterJoin(f).on(p.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(p.RDB$PROCEDURE_NAME.eq(getName())).and(p.RDB$PARAMETER_TYPE.eq((short) 1)).orderBy(p.RDB$PARAMETER_NUMBER)) {
DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHARACTER_LENGTH", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(p.RDB$NULL_FLAG) == 0, record.get(p.RDB$DEFAULT_SOURCE));
ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(p.RDB$PARAMETER_NAME.trim()), record.get(p.RDB$PARAMETER_NUMBER), type, false, null);
result.add(column);
}
return result;
}
use of org.jooq.util.firebird.rdb.tables.Rdb$fields in project atlasmap by atlasmap.
the class AtlasXmlModelFactory method createXmlDocument.
public static XmlDocument createXmlDocument() {
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.setFields(new Fields());
return xmlDocument;
}
Aggregations