存储过程问题(急!马上给分)

sunrise10 2004-12-03 10:02:36
create procedure pc_updateMagaType
@iBigClassID_Old int,
@iClassID_Old int,
@iSubClassID_Old int,
@iBigClassID_New int,
@iClassID_New int,
@iSubClassID_New int
as
declare magaID int
--将杂志数据放入游标
if @iClassID_Old=0
begin
--当类别为空时
DECLARE magack_info CURSOR for select * from magack_tbl where maga_id = @iBigClassID_Old
end
else
begin
if @iSubClassID_Old = 0
begin
DECLARE magack_info CURSOR for select * from magack_tbl where magackid in (select DISTINCT magackid from graph_tbl where magaid= @iClassID_Old)
end
else
begin
DECLARE magack_info CURSOR for select magafiles,magafilepath from magack_tbl where magackid in (select DISTINCT magackid from graph_tbl where magaid= @iClassID_Old and subClass = @iSubClassID_Old)
end
end
可以这么定义吗?
为什么我定义declare magaID int他提示错误:int不可识别的游标选项
以上语句还有什么错误???
...全文
141 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunrise10 2004-12-03
  • 打赏
  • 举报
回复
存储过程里怎么取系统时间
老马2008 2004-12-03
  • 打赏
  • 举报
回复
如果说还有什么错误的话,游标用完要关闭,释放哦
close magack_info
deallocate magack_info
lh1979 2004-12-03
  • 打赏
  • 举报
回复
变量定义变量前必须加@,
tddw 2004-12-03
  • 打赏
  • 举报
回复
上面一条语句就将查询结果的值赋给@magaID了
tddw 2004-12-03
  • 打赏
  • 举报
回复
select @magaID = 字段名 from 表名 where 条件
tddw 2004-12-03
  • 打赏
  • 举报
回复
改成:declare @magaID int
sunrise10 2004-12-03
  • 打赏
  • 举报
回复
我想接下来,把一个查询结果的一个字段赋值给@magaid,该怎么做呢??????
Liroyal 2004-12-03
  • 打赏
  • 举报
回复
declare @magaID cursor
scorpiowell 2004-12-03
  • 打赏
  • 举报
回复
不好意思写错了,getdate
scorpiowell 2004-12-03
  • 打赏
  • 举报
回复
取系统时间gettime

34,872

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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