SQLStatement sqlStmt = stmtList.get(0);
if (sqlStmt instanceof SQLSelectStatement) {
SQLSelectStatement selectStmt = (SQLSelectStatement) sqlStmt;
SQLEvalVisitor evalVisitor = SQLEvalVisitorUtils.createEvalVisitor(dbType);
selectStmt.accept(evalVisitor);
SQLSelectQueryBlock selectQueryBlock = (SQLSelectQueryBlock) selectStmt.getSelect().getQuery();
SQLExprTableSource tableSource = (SQLExprTableSource) selectQueryBlock.getFrom();
String tableName = ((SQLIdentifierExpr) tableSource.getExpr()).getName();
SingleTableQueryExecutePlan singleTableQueryExecuetePlan = new SingleTableQueryExecutePlan();
singleTableQueryExecuetePlan.setMapping(mapping);
singleTableQueryExecuetePlan.setTableName(tableName);
splitCondition(singleTableQueryExecuetePlan.getConditions(), selectQueryBlock.getWhere());
HResultSetMetaDataImpl resultMetaData = new HResultSetMetaDataImpl();
for (SQLSelectItem selectItem : selectQueryBlock.getSelectList()) {
ColumnMetaData columnMetaData = new ColumnMetaData();
if (selectItem.getAlias() != null) {
columnMetaData.setColumnLabel(selectItem.getAlias());
}
columnMetaData.setColumnName(SQLUtils.toSQLString(selectItem.getExpr(), dbType));
columnMetaData.setColumnType(Types.BINARY);
resultMetaData.getColumns().add(columnMetaData);
}
singleTableQueryExecuetePlan.setResultMetaData(resultMetaData);
this.executePlan = singleTableQueryExecuetePlan;
} else if (sqlStmt instanceof SQLInsertStatement) {
SQLInsertStatement insertStmt = (SQLInsertStatement) sqlStmt;
SQLEvalVisitor evalVisitor = SQLEvalVisitorUtils.createEvalVisitor(dbType);
insertStmt.accept(evalVisitor);
String tableName = ((SQLIdentifierExpr) insertStmt.getTableSource().getExpr()).getName();
InsertExecutePlan insertExecutePlan = new InsertExecutePlan();