private void addParameter(StatementBuilder buff, Column col) { if (col.getType() == Value.STRING_FIXED && link.isOracle()) { // workaround for Oracle // create table test(id int primary key, name char(15)); // insert into test values(1, 'Hello') // select * from test where name = ? -- where ? = "Hello" > no rows buff.append("CAST(? AS CHAR(").append(col.getPrecision()).append("))"); } else { buff.append('?'); } }
private void buildDeleteSQL() { if (deleteAction == ConstraintActionType.RESTRICT) { return; } StatementBuilder buff = new StatementBuilder(); if (deleteAction == ConstraintActionType.CASCADE) { buff.append("DELETE FROM ").append(table.getSQL()); } else { appendUpdate(buff); } appendWhere(buff); deleteSQL = buff.toString(); }
/** * @param buff Statement builder. * @param exp Alias expression. */ private static void addAlias(StatementBuilder buff, GridSqlAst exp) { exp = GridSqlAlias.unwrap(exp); buff.append(StringUtils.unEnclose(exp.getSQL())); }
private String getKey(Object[] row) throws SQLException { StatementBuilder buff = new StatementBuilder(); for (int columnIndex : index.keys) { buff.appendExceptFirst(" AND "); buff.append(StringUtils.quoteIdentifier(index.columns[columnIndex])); Object o = row[columnIndex]; if (o == null) { buff.append(" IS NULL"); } else { buff.append('=').append(quoteSQL(o, columnTypes[columnIndex])); } } return buff.toString(); }
@Override public String getSQL() { StatementBuilder buff = new StatementBuilder(); buff.append(Parser.quoteIdentifier(userAggregate.getName())).append('('); for (Expression e : args) { buff.appendExceptFirst(", "); buff.append(e.getSQL()); } buff.append(')'); if (filterCondition != null) { buff.append(" FILTER (WHERE ").append(filterCondition.getSQL()).append(')'); } return buff.toString(); }
/** * Get the list of columns as a string. * * @return the list of columns */ private String getColumnListSQL() { StatementBuilder buff = new StatementBuilder(); for (IndexColumn c : indexColumns) { buff.appendExceptFirst(", "); buff.append(c.getSQL()); } return buff.toString(); }
private DbException getSyntaxError() { if (expectedList == null || expectedList.isEmpty()) { return DbException.getSyntaxError(sqlCommand, parseIndex); } StatementBuilder buff = new StatementBuilder(); for (String e : expectedList) { buff.appendExceptFirst(", "); buff.append(e); } return DbException.getSyntaxError(sqlCommand, parseIndex, buff.toString()); }