谢谢。。我先试一下DECLARE ShenPi_cursor CURSOR FOR select distinct(a.ApplyId),b.AuditeStep from t_Apply a, t_Audite b where b.UserId=@UserId and b.Depart=@Depart and a.ApplyState=0 or a.ApplyState=1 从这里面读数FETCH NEXT FROM ShenPi_cursor INTO @APID, @AUSTEP 读出的数放入@APID, @AUSTEP 两个变量中,,,通过这辆个变量去判断取数。
现在在分析器中测试: DECLARE @APID VARCHAR(15) DECLARE @AUSTEP INT DECLARE @AUSTEP_PRO INT DECLARE @SHENPI_FLAG INTDECLARE ShenPi_cursor CURSOR FOR select distinct(a.ApplyId),b.AuditeStep from t_Apply a, t_Audite b where b.UserId='孙伟平' and b.Depart='销售部' and a.ApplyState=0 or a.ApplyState=1 OPEN ShenPi_cursor
FETCH NEXT FROM ShenPi_cursor INTO @APID, @AUSTEP print @APID PRINT @AUSTEPCLOSE ShenPi_cursor DEALLOCATE ShenPi_cursor就只能够取道第一条记录?是什么原因?
删除游标引用。当释放最后的游标引用时,组成该游标的数据结构由 Microsoft® SQL Server™ 释放。
select distinct(a.ApplyId),b.AuditeStep from t_Apply a, t_Audite b where b.UserId=@UserId and b.Depart=@Depart and a.ApplyState=0 or a.ApplyState=1 从这里面读数FETCH NEXT FROM ShenPi_cursor INTO @APID, @AUSTEP
读出的数放入@APID, @AUSTEP
两个变量中,,,通过这辆个变量去判断取数。
DECLARE @APID VARCHAR(15)
DECLARE @AUSTEP INT
DECLARE @AUSTEP_PRO INT
DECLARE @SHENPI_FLAG INTDECLARE ShenPi_cursor CURSOR FOR
select distinct(a.ApplyId),b.AuditeStep from t_Apply a, t_Audite b
where b.UserId='孙伟平' and b.Depart='销售部' and a.ApplyState=0 or a.ApplyState=1 OPEN ShenPi_cursor
FETCH NEXT FROM ShenPi_cursor INTO @APID, @AUSTEP
print @APID
PRINT @AUSTEPCLOSE ShenPi_cursor
DEALLOCATE ShenPi_cursor就只能够取道第一条记录?是什么原因?
提示ShenPi_cursor已经存在???
2--DEALLOCATE ShenPi_cursor 放在最上面同样只可以取到一条记录?是什么原因???
BEGIN ........... END