我想返回row_number按变量模型类:
在我探索的示例中,PreparedStatament是列名。 row_number不是表的本机列或物理列。将返回如何使值dete方法变为实际物理表列的方式。在表中创建一个新列以仅存储这些值也不会很有趣。我也不打算使用触发器返回这些值。可以通过这种方式完成,而在下面的代码中没有错误。
final StringBuffer lSql = new StringBuffer();
lSql.append("SELECT ");
lSql.append(" TABLE_NAME.ROW_NUMBER() OVER (ORDER BY COLUMN_DAY) ");
lSql.append("FROM ...");
// ...
final List<classModel> listData = new ArrayList<classModel>();
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rset = null;
try{
conn = getConnection1();
stmt = conn.prepareStatement(lSql.toString());
int count = 1;
//stmt.setLong(count++, classModelParameterThisFunctionDAO.getVarColumnSequence());
//...
rset = stmt.executeQuery(); // ERROR THIS LINE NI DEBUG
while(rset.nex()){
final classModel lClassModel = new classModel();
lClassModel.setColumnSequence(rset.getInt("ROW_NUMBER() OVER (ORDER BY COLUMN_DAY)")); //error in this line
listData.add(lClassModel);
最佳答案
lSql.append("SELECT ");
lSql.append(" TABLE_NAME.ROW_NUMBER() OVER (ORDER BY COLUMN_DAY) as RRN ");
lSql.append("FROM ...")
.
.
.
lClassModel.setColumnSequence(rset.getInt("RRN"));