TOP arguments can't be parameterized, use $quantity$ and $offset$ instead.
________________________________ From: Sergey Livanov [mailto:[EMAIL PROTECTED] Sent: dinsdag 20 november 2007 18:56 To: user-java Subject: sql server paging I want to make paging for mssql server. I use a design SELECT * FROM ( SELECT TOP #quantity # * FROM ( SELECT TOP #offset# * FROM c1db.dbo.accounts a ORDER BY DOCDATE desc, docnum desc) as acc ORDER BY DOCDATE asc, docnum asc) as docs ORDER BY DOCDATE desc, docnum desc I receive the following error DEBUG [http-8080-Processor24] java.sql.Connection debug- {conn-100039} Connection DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug- {pstm-100040} PreparedStatement: SELECT * FROM ( SELECT TOP ? * FROM ( SELECT TOP ? * FROM c1db.dbo.accounts a ORDER BY DOCDATE desc, docnum desc ) as acc ORDER BY DOCDATE asc, docnum asc ) as docs ORDER BY DOCDATE desc, docnum desc DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug- {pstm-100040} Parameters: [120, 121] DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug- {pstm-100040} Types: [java.lang.Long, java.lang.Long ] org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in AccountsSQL.xml . What should I do ?
