jueljust 发表于 2006-4-29 10:58:33

分页存储调用出错

<p>有一个分页存储过程如下</p><pre><code><br/>CREATE PROCEDURE GetDataByPage<br/>(<br/>&nbsp;&nbsp;&nbsp; @SqlStr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; varchar(8000),<br/>&nbsp;&nbsp;&nbsp; @PageSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int,<br/>&nbsp;&nbsp;&nbsp; @CurrentPage&nbsp;&nbsp;&nbsp; int<br/>)<br/>AS<br/><br/>DECLARE @FirstRec int, @LastRec int,@dt varchar(10)<br/><br/>BEGIN<br/><p></p><p>&nbsp; SELECT @FirstRec = (@CurrentPage - 1) * @PageSize<br/>&nbsp; SELECT @LastRec = (@CurrentPage * @PageSize + 1)</p><p>&nbsp; SELECT @dt= substring(convert(varchar,rand()),3,10)<br/>&nbsp; <br/>&nbsp; SELECT @SqlStr = stuff(@SqlStr,charindex(' FROM ',upper(@SqlStr)),6,' INTO <a href="mailto:tempdb..Paging'+@dt+'">tempdb..Paging'+@dt+'</a> FROM ')<br/>&nbsp; EXECUTE (@SqlStr)</p><p>&nbsp; SELECT @SqlStr = 'ALTER TABLE <a href="mailto:tempdb..Paging'+@dt+'">tempdb..Paging'+@dt+'</a> ADD RID numeric(10) IDENTITY PRIMARY KEY'<br/>&nbsp; EXECUTE (@SqlStr)<br/>&nbsp; <br/>&nbsp; SELECT @SqlStr = 'SELECT Count(*) From <a href="mailto:tempdb..Paging'+@dt">tempdb..Paging'+@dt</a><br/>&nbsp; EXECUTE (@SqlStr)<br/>&nbsp; <br/>&nbsp; SELECT @SqlStr = 'SELECT * FROM <a href="mailto:tempdb..Paging'+@dt+'">tempdb..Paging'+@dt+'</a> WHERE RID &gt;; '+convert(varchar,@FirstRec)+' and RID &lt; '+convert(varchar,@LastRec)<br/>&nbsp; EXECUTE (@SqlStr)<br/>&nbsp; <br/>&nbsp; SELECT @SqlStr = 'DROP TABLE <a href="mailto:tempdb..Paging'+@dt">tempdb..Paging'+@dt</a><br/>&nbsp; EXECUTE (@SqlStr) <br/>&nbsp; <br/>END</p></code></pre><p>调用时,输入<br/>&gt;GetDataByPage('SELECT * FROM DateTime', 1, 1)<br/>&gt;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编辑过]

jueljust 发表于 2006-4-30 09:58:23

<p>解决了,调用语法不对,去掉括号就行了</p>

dingon 发表于 2006-8-12 16:24:36

<p>你的原始表里没有identity字段吧????</p><p>如果有这个自增长字段,如何翻页呢?????一张表不允许两个identity字段的!!!!</p><p>头都大了.ft</p>

sybasefa 发表于 2007-3-20 16:00:39

<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]
查看完整版本: 分页存储调用出错

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com