Sql语句介绍:游标

mac2022-06-30  57

游标 declare @ID int@PID int@Ver intdeclare #cur cursor for select 1 as ID,1 as ParentId,1 as Versionunion select 212 union select 313open #curfetch next from #cur into @ID@PID@Verwhile @@FETCH_STATUS=0begin    print('do some thing.')    fetch next from #cur into @ID@PID@Verendclose #curdeallocate #cur

 

其中fetch next from #cur into @ID, @PID, @Ver是读取当前行的记录,按Column的顺序放到这三个变量中。

等同select @ID=ID,@PID=PID,@Ver=Ver from table where 条件.

转载于:https://www.cnblogs.com/KenBlove/archive/2009/02/10/1387250.html

相关资源:Mysql中sql语句游标详解
最新回复(0)