我有以下查询, 当我尝试使用hibernate执行它时,我得到以下异常:
org.hibernate.exception.SQLGrammarException:无法执行查询 使用滚动。
在我的代码中,我的滚动有FORWARD_ONLY。 任何人都可以提供完美的解决方案。
select * from (SELECT account_no AS accountno,rownum r FROM sc_dcm_postpaid_index WHERE groupid = 'SBG-2012'
and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12'
AND ROWID IN (SELECT MAX(ROWID) AS row_no ; FROM sc_dcm_postpaid_index
WHERE groupid= 'SBG-2012' and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12'
GROUP BY account_no HAVING COUNT (account_no) >= 1 ) ORDER BY account_no)where r >= 11 and r <= 21..
当我将查询更改为
时SELECT account_no AS accountno,rownum r FROM sc_dcm_postpaid_index WHERE rownum >= 11 and rownum <= 21 groupid = 'SBG-2012'
and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12'
AND ROWID IN (SELECT MAX(ROWID) AS row_no ; FROM sc_dcm_postpaid_index
WHERE groupid= 'SBG-2012' and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12'
GROUP BY account_no HAVING COUNT (account_no) >= 1 ) ORDER BY account_no
这是我的查询:
SQLQuery mainQuery = (SQLQuery) session.createSQLQuery(strReportQuery);
ScrollableResults itrDataList = mainQuery.scroll(ScrollMode.FORWARD_ONLY);
此处strReportQuery
是我的查询
它执行正常,但它仅适用于rownum 1到10。 从下一个rownum开始,它将结果集显示为空。
先谢谢, Bhargavi T。