}
}
public Cursor find(Session session, SearchRow first, SearchRow last) {
ArrayList<Value> params = New.arrayList();
StatementBuilder buff = new StatementBuilder("SELECT * FROM ");
buff.append(targetTableName).append(" T");
for (int i = 0; first != null && i < first.getColumnCount(); i++) {
Value v = first.getValue(i);
if (v != null) {
buff.appendOnlyFirst(" WHERE ");
buff.appendExceptFirst(" AND ");
Column col = table.getColumn(i);
buff.append(col.getSQL());
if (v == ValueNull.INSTANCE) {
buff.append(" IS NULL");
} else {
buff.append(">=");
addParameter(buff, col);
params.add(v);
}
}
}
for (int i = 0; last != null && i < last.getColumnCount(); i++) {
Value v = last.getValue(i);
if (v != null) {
buff.appendOnlyFirst(" WHERE ");
buff.appendExceptFirst(" AND ");
Column col = table.getColumn(i);
buff.append(col.getSQL());
if (v == ValueNull.INSTANCE) {
buff.append(" IS NULL");
} else {
buff.append("<=");
addParameter(buff, col);
params.add(v);
}
}
}
String sql = buff.toString();
try {
PreparedStatement prep = link.execute(sql, params, false);
ResultSet rs = prep.getResultSet();
return new LinkedCursor(link, rs, session, sql, prep);
} catch (Exception e) {