sybase 动态游标怎么写

kisshexuxia 2016-10-27 08:47:32
最近刚接触sybase数据库写存储过程中用到游标时候碰到一个问题

第一种动态生成游标
 
DECLARE @where varchar(1000)
select @where=' where 1=1 AND id=10000004'
EXEC('DECLARE cursor_a CURSOR FOR select distinct(ID) from table @where')


执行存储过程报
ErrorMessage: The cursor 'cursor_a' can not be used as it could not be found. It is possible that either it was not declared or it is not available in the current context.

第二种静态写死
    DECLARE cursor_a CURSOR  FOR select  distinct(ID) from table  where  1=1 AND id=10000004 


这样写没问题请问SYBASE 动态游标要怎么写
...全文
1912 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
sybase中游标的SQL只能使用静态SQL,无法创建动态游标。 建议:你可以将动态内容创建临时存储过程然后通过参数化调用临时存储过程。
kisshexuxia 2017-02-20
  • 打赏
  • 举报
回复
我靠、尽然是我自己提的问题!!!!
kisshexuxia 2017-02-20
  • 打赏
  • 举报
回复
我也想知道,动态的不知道怎么写

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧