public void setFrom(SQLSelect select, String alias) { if (select == null) { this.from = null; return; } SQLSubqueryTableSource from = new SQLSubqueryTableSource(select); from.setAlias(alias); this.setFrom(from); }
private static String createCountUseSubQuery(SQLSelect select, String dbType) { SQLSelectQueryBlock countSelectQuery = createQueryBlock(dbType); SQLSelectItem countItem = createCountItem(dbType); countSelectQuery.getSelectList().add(countItem); SQLSubqueryTableSource fromSubquery = new SQLSubqueryTableSource(select); fromSubquery.setAlias("ALIAS_COUNT"); countSelectQuery.setFrom(fromSubquery); SQLSelect countSelect = new SQLSelect(countSelectQuery); SQLSelectStatement countStmt = new SQLSelectStatement(countSelect, dbType); return SQLUtils.toSQLString(countStmt, dbType); }
static void resolve(SchemaResolveVisitor visitor, SQLParameter x) { SQLName name = x.getName(); if (name instanceof SQLIdentifierExpr) { ((SQLIdentifierExpr) name).setResolvedParameter(x); } SQLExpr expr = x.getDefaultValue(); SchemaResolveVisitor.Context ctx = null; if (expr != null) { if (expr instanceof SQLQueryExpr) { ctx = visitor.createContext(x); SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(((SQLQueryExpr) expr).getSubQuery()); tableSource.setParent(x); tableSource.setAlias(x.getName().getSimpleName()); ctx.setTableSource(tableSource); } expr.accept(visitor); } if (ctx != null) { visitor.popContext(); } }
public void setFrom(SQLSelect select, String alias) { if (select == null) { this.from = null; return; } SQLSubqueryTableSource from = new SQLSubqueryTableSource(select); from.setAlias(alias); this.setFrom(from); }
private static String createCountUseSubQuery(SQLSelect select, String dbType) { SQLSelectQueryBlock countSelectQuery = createQueryBlock(dbType); SQLSelectItem countItem = createCountItem(dbType); countSelectQuery.getSelectList().add(countItem); SQLSubqueryTableSource fromSubquery = new SQLSubqueryTableSource(select); fromSubquery.setAlias("ALIAS_COUNT"); countSelectQuery.setFrom(fromSubquery); SQLSelect countSelect = new SQLSelect(countSelectQuery); SQLSelectStatement countStmt = new SQLSelectStatement(countSelect, dbType); return SQLUtils.toSQLString(countStmt, dbType); }
static void resolve(SchemaResolveVisitor visitor, SQLParameter x) { SQLName name = x.getName(); if (name instanceof SQLIdentifierExpr) { ((SQLIdentifierExpr) name).setResolvedParameter(x); } SQLExpr expr = x.getDefaultValue(); SchemaResolveVisitor.Context ctx = null; if (expr != null) { if (expr instanceof SQLQueryExpr) { ctx = visitor.createContext(x); SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(((SQLQueryExpr) expr).getSubQuery()); tableSource.setParent(x); tableSource.setAlias(x.getName().getSimpleName()); ctx.setTableSource(tableSource); } expr.accept(visitor); } if (ctx != null) { visitor.popContext(); } }