CREATE PROCEDURE [dbo].[DeviceClassified] AS
Declare @frTe int
Declare @toTe int
Declare @baseTe int
Declare @plusTe int
set @baseTe=0
set @plusTe=0 --Lead table
Declare cursor_lead Cursor For
SELECT F1014_FTID,F1014_TTID FROM TB1014_LEAD
For Update OPEN cursor_lead
While(0=0)
BEGIN
Fetch Next From cursor_lead Into @frTe,@toTe
if(@@Fetch_Status<>0) Break
set @baseTe = @plusTe+1
set @plusTe = @baseTe+1
Update TB1014_LEAD Set F1014_FTID=@baseTe,F1014_TTID=@plusTe
Where Current of cursor_lead
END Close cursor_lead
Deallocate cursor_lead
MySQLSQL ServerCursor存储迁移
Declare @frTe int
Declare @toTe int
Declare @baseTe int
Declare @plusTe int
set @baseTe=0
set @plusTe=0 --Lead table
Declare cursor_lead Cursor For
SELECT F1014_FTID,F1014_TTID FROM TB1014_LEAD
For Update OPEN cursor_lead
While(0=0)
BEGIN
Fetch Next From cursor_lead Into @frTe,@toTe
if(@@Fetch_Status<>0) Break
set @baseTe = @plusTe+1
set @plusTe = @baseTe+1
Update TB1014_LEAD Set F1014_FTID=@baseTe,F1014_TTID=@plusTe
Where Current of cursor_lead
END Close cursor_lead
Deallocate cursor_lead
MySQLSQL ServerCursor存储迁移
CREATE PROCEDURE curdemo(IN V_GROUP INT)
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE a INT;
DECLARE b CHAR(16);
DECLARE cur1 CURSOR FOR SELECT id,name FROM student where classid=V_GROUP;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur1;
REPEAT
FETCH cur1 INTO a, b;
select a,b;
UNTIL done END REPEAT;
CLOSE cur1;
END;
For UpdateOPEN cursor_lead
While(0=0)
BEGIN
Fetch Next From cursor_lead Into @frTe,@toTe
if(@@Fetch_Status<>0) Break
set @baseTe = @plusTe+1
set @plusTe = @baseTe+1
Update TB1014_LEAD Set F1014_FTID=@baseTe,F1014_TTID=@plusTe
Where Current of cursor_lead
END
这块怎么转,select for update 。,大侠能给我转下么,大概正确就行了编译我来调整,分数都给你
DECLARE done INT DEFAULT 0;
DECLARE a INT;
DECLARE b CHAR(16);
Declare cursor_lead Cursor For
SELECT F1014_FTID,F1014_TTID FROM TB1014_LEAD;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cursor_lead;
REPEAT
FETCH cursor_lead INTO @frTe,@toTe;
set @baseTe = @plusTe+1;
set @plusTe = @baseTe+1;
Update TB1014_LEAD Set F1014_FTID=@baseTe,F1014_TTID=@plusTe;
UNTIL done END REPEAT;
CLOSE cursor_lead;