马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
sybase 中正确操作游标的顺序是: 1、DECLARE CUR_ACCTINFO CURSOR FOR SELECT ..... (定义) 2、OPEN CUR_ACCTINFO (打开)
3、WHILE @@SQLSTATUS = 0 (判断是否成功) BEGIN
4、 FETCH CUR_ACCTINFO INTO ....... (取数据) IF @@SQLSTATUS <> 0 begin ...... end ........... 5、 CLOSE CUR_ACCTINFO (关闭) 6、 DEALLOCATE CURSOR CUR_ACCTINFO (释放)
别人的一个DEMO:
CREATE PROCEDURE up_pos_zyinout (@arg_year datetime, @arg_prd int ) AS declare @temp_shop varchar(40) declare cur_shop cursor for select ORGAN_ID from F_SALE_DEPT where ORGAN_ID LIKE "281%" OPEN cur_shop fetch cur_shop into @temp_shop while @@sqlstatus = 0 begin exec up_accrpt_zyposinout @arg_year,@arg_prd,"",@temp_shop,"n","y" fetch cur_shop into @temp_shop end close cur_shop DEALLOCATE cursor cur_shop
|