public static JdbcTimestampBoundStore create(final JdbcKeyValueService kvs) { final JdbcTimestampBoundStore store = new JdbcTimestampBoundStore(kvs); kvs.run((Function<DSLContext, Void>) ctx -> { String partialSql = ctx.createTable(store.TABLE) .column(DUMMY_COLUMN, INTEGER.nullable(false)) .column(LATEST_TIMESTAMP, BIGINT.nullable(false)) .getSQL(); int endIndex = partialSql.lastIndexOf(')'); String fullSql = partialSql.substring(0, endIndex) + "," + " CONSTRAINT " + kvs.primaryKey(TIMESTAMP_TABLE) + " PRIMARY KEY (" + DUMMY_COLUMN.getName() + ")" + partialSql.substring(endIndex); try { ctx.execute(fullSql); } catch (DataAccessException e) { kvs.handleTableCreationException(e); } ctx.insertInto(store.TABLE, DUMMY_COLUMN, LATEST_TIMESTAMP) .select(ctx.select(DUMMY_COLUMN, LATEST_TIMESTAMP) .from(kvs.values(ctx, new RowN[] {(RowN) DSL.row(0, 10000L)}, "t", DUMMY_COLUMN.getName(), LATEST_TIMESTAMP.getName())) .whereNotExists(ctx.selectOne() .from(store.TABLE) .where(DUMMY_COLUMN.eq(0)))) .execute(); return null; }); return store; }
.select(ctx.select(T1_ROW_NAME, T1_COL_NAME, T1_TIMESTAMP, T1_VALUE) .from(values(ctx, rows, TEMP_TABLE_1, ROW_NAME, COL_NAME, TIMESTAMP, VALUE)) .whereNotExists(ctx.selectOne() .from(atlasTable(tableRef).as(ATLAS_TABLE)) .where(A_ROW_NAME.eq(T1_ROW_NAME)
.whereNotExists( selectOne() .from(divisor) .whereNotExists( selectOne() .from(dividend)
.whereNotExists( selectOne() .from(divisor) .whereNotExists( selectOne() .from(dividend)