"cast(RF.RDB$RELATION_NAME as varchar(" + OBJECT_NAME_LENGTH + ")) AS TABLE_NAME,\n" +
"cast(RF.RDB$FIELD_NAME as varchar(" + OBJECT_NAME_LENGTH + ")) AS COLUMN_NAME,\n" +
"F.RDB$FIELD_TYPE AS DATA_TYPE,\n" +
"F.RDB$FIELD_SUB_TYPE AS TYPE_NAME,\n" +
"F.RDB$FIELD_PRECISION AS COLUMN_SIZE,\n" +
"F.RDB$FIELD_SCALE AS BUFFER_LENGTH,\n" +
"F.RDB$FIELD_LENGTH AS DECIMAL_DIGITS,\n" +
"F.RDB$CHARACTER_LENGTH AS CHAR_LEN,\n" +
"RF.RDB$DESCRIPTION AS REMARKS,\n" +
"RF.RDB$DEFAULT_SOURCE AS DEFAULT_SOURCE,\n" +
"F.RDB$DEFAULT_SOURCE AS DOMAIN_DEFAULT_SOURCE,\n" +
"RF.RDB$FIELD_POSITION + 1 AS FIELD_POSITION,\n" +
"RF.RDB$NULL_FLAG AS NULL_FLAG,\n" +
"F.RDB$NULL_FLAG AS SOURCE_NULL_FLAG,\n" +
"F.RDB$COMPUTED_BLR AS COMPUTED_BLR,\n" +
"F.RDB$CHARACTER_SET_ID,\n" +
"RF.RDB$FIELD_SOURCE,\n");
if (hasIdentityColumns(session)) {
sql.append("CASE WHEN RF.RDB$IDENTITY_TYPE IS NULL THEN CAST('NO' AS VARCHAR(3)) ELSE CAST('YES' AS VARCHAR(3)) END AS IS_IDENTITY,\n" +
"CASE RF.RDB$IDENTITY_TYPE WHEN 0 THEN CAST('ALWAYS' AS VARCHAR(10)) WHEN 1 THEN CAST('BY DEFAULT' AS VARCHAR(10)) ELSE NULL END AS JB_IDENTITY_TYPE\n" +
"FROM RDB$RELATION_FIELDS RF,RDB$FIELDS F");
} else {
sql.append("'NO' AS IS_IDENTITY,\n" +
"CAST(NULL AS VARCHAR(10)) AS JB_IDENTITY_TYPE\n" +
try(JDBCPreparedStatementdbStat=session.prepareStatement("SELECT RF.RDB$FIELD_NAME,RF.RDB$FIELD_SOURCE FROM RDB$RELATION_FIELDS RF WHERE RF.RDB$RELATION_NAME=?")){
try(JDBCPreparedStatementdbStat=session.prepareStatement("SELECT RF.RDB$FIELD_SOURCE FROM RDB$RELATION_FIELDS RF WHERE RF.RDB$RELATION_NAME=? AND RF.RDB$FIELD_NAME=?")){