分页存储调用出错
<p>有一个分页存储过程如下</p><pre><code><br/>CREATE PROCEDURE GetDataByPage<br/>(<br/> @SqlStr varchar(8000),<br/> @PageSize int,<br/> @CurrentPage int<br/>)<br/>AS<br/><br/>DECLARE @FirstRec int, @LastRec int,@dt varchar(10)<br/><br/>BEGIN<br/><p></p><p> SELECT @FirstRec = (@CurrentPage - 1) * @PageSize<br/> SELECT @LastRec = (@CurrentPage * @PageSize + 1)</p><p> SELECT @dt= substring(convert(varchar,rand()),3,10)<br/> <br/> SELECT @SqlStr = stuff(@SqlStr,charindex(' FROM ',upper(@SqlStr)),6,' INTO <a href="mailto:tempdb..Paging'+@dt+'">tempdb..Paging'+@dt+'</a> FROM ')<br/> EXECUTE (@SqlStr)</p><p> SELECT @SqlStr = 'ALTER TABLE <a href="mailto:tempdb..Paging'+@dt+'">tempdb..Paging'+@dt+'</a> ADD RID numeric(10) IDENTITY PRIMARY KEY'<br/> EXECUTE (@SqlStr)<br/> <br/> SELECT @SqlStr = 'SELECT Count(*) From <a href="mailto:tempdb..Paging'+@dt">tempdb..Paging'+@dt</a><br/> EXECUTE (@SqlStr)<br/> <br/> SELECT @SqlStr = 'SELECT * FROM <a href="mailto:tempdb..Paging'+@dt+'">tempdb..Paging'+@dt+'</a> WHERE RID >; '+convert(varchar,@FirstRec)+' and RID < '+convert(varchar,@LastRec)<br/> EXECUTE (@SqlStr)<br/> <br/> SELECT @SqlStr = 'DROP TABLE <a href="mailto:tempdb..Paging'+@dt">tempdb..Paging'+@dt</a><br/> EXECUTE (@SqlStr) <br/> <br/>END</p></code></pre><p>调用时,输入<br/>>GetDataByPage('SELECT * FROM DateTime', 1, 1)<br/>>go</p><p>返回消息<br/>Msg 102, Level 15, State 1:<br/>Line 1:<br/>Incorrect syntax near 'SELECT * FROM DateTime'.</p><p>请问哪里出错了</p>[此贴子已经被作者于2006-4-29 10:59:09编辑过]
<p>解决了,调用语法不对,去掉括号就行了</p> <p>你的原始表里没有identity字段吧????</p><p>如果有这个自增长字段,如何翻页呢?????一张表不允许两个identity字段的!!!!</p><p>头都大了.ft</p> <p>我分页也是用的这个存储过程,在java中调用,可是我的SQL语句是</p><p>"select EntRegNO,EntName,QYLX,EntStatus,BuItem from td_vobject where 1=1 and EntName like '%管理有限公司'"</p><p>执行的时候报:com.sybase.jdbc2.jdbc.SybSQLException: The identifier that starts with '"set rowcount 100 select EntR' is too long. Maximum length is 28.这个错误,是什么原因啊,请高手指教,小弟第一次用sybase数据库,谢谢</p>
页:
[1]