DECLARE @CauseCode VARCHAR(10) ,
@ProtocolCode VARCHAR(10) ,
@line VARCHAR(20) ,
@tmp VARCHAR(10)
DECLARE mycur CURSOR
FOR
SELECT ROW_NUMBER() OVER ( ORDER BY t.AUTHReqTime ASC ) ,
t.CauseCode ,
t.ProtocolCode
FROM T_WLan_CDR_Portal t FOR UPDATE
BEGIN
OPEN mycur ;
FETCH NEXT FROM mycur INTO @line, @CauseCode, @ProtocolCode ;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT '行号:' + @line + '协议码:' + @ProtocolCode + ' 错误码:'
+ @CauseCode ;
SET @tmp = @ProtocolCode ;
SET @ProtocolCode = @CauseCode ;
SET @CauseCode = @tmp ;
PRINT '行号:' + @line + '协议码:' + @ProtocolCode + ' 错误码:'
+ @CauseCode ;
UPDATE T_WLan_CDR_Portal
SET CauseCode = @ProtocolCode ,
ProtocolCode = @CauseCode
WHERE CURRENT OF mycur ;
FETCH NEXT FROM mycur INTO @line, @CauseCode, @ProtocolCode ;
详细解决方案
sqlSever 游标更新时报错:游标只读,该怎么处理
热度:246 发布时间:2016-04-24 20:26:04.0