关于游标的问题》》》》》
在存储过程中使用了游标,如下,
但在查询分析器中执行这个存储过程,总是提示游标已经存在????
begin
DECLARE @APID VARCHAR(15)
DECLARE @AUSTEP INT
DECLARE @AUSTEP_PRO INT
DECLARE @SHENPI_FLAG INT
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
OPEN ShenPi_cursor
FETCH NEXT FROM ShenPi_cursor INTO @APID, @AUSTEP
BEGIN
IF @AUSTEP=0
BEGIN
SET @AUSTEP_PRO=@AUSTEP
××××××
END
ELSE
BEGIN
SET @AUSTEP_PRO=@AUSTEP-1
SELECT @SHENPI_FLAG=AuditeDetail from t_Audite where ApplyId=@APID and AuditeStep=@AUSTEP_PRO
if @SHENPI_FLAG=3 or @SHENPI_FLAG=4 /*3-4都可以通过*/
BEGIN
××××××
END
END
END
CLOSE ShenPi_cursor
DEALLOCATE ShenPi_cursor
select * from #t_temp
drop TABLE #t_temp
end
DEALLOCATE ShenPi_cursor这句起什么作用???我是看帮助里面有才写入的》》》