update......where current of...

ymslx-2007
update......where current of...

foreach cur001 for
        select mkno_start_val, mkno_max_val, mkno_now_val
          into w_start_num , w_max_num , w_current_num
        from hulft_dt_f_mkno
        where hulft_id = p_hulft_id
        
        if  w_max_num  <  w_current_num  then
            let w_current_num = w_start_num;
            update hulft_dt_f_mkno
               set mkno_now_val  = w_current_num,
                   upd_date_time = w_time
             where current of cur001;
        end if
        exit foreach;
    end foreach;
以上代码编译没问题,可就是执行时回出-255的错。
希望高手指教!谢谢

liaosnet
-255    Not in transaction.

The database server cannot execute this COMMIT WORK or ROLLBACK WORK
statement because no BEGIN WORK was executed to start a transaction.
Because no transaction was started, you cannot end one. Any database
modifications that were made are now permanent; they cannot be rolled
back but do not need to be committed. Review the sequence of SQL
statements to see where the transaction should have started.

This error can occur when you open a cursor for update and have not started
a transaction yet.

ymslx-2007
回复 #1 ymslx-2007 的帖子

谢谢啦,我也可以看到出错信息,就是不知道代码有那里写错啦。
如果各位有“where current of ”的用法发过来参考以下,不胜感激!!

mush57
你把foreach cur001 for這行改成foreach cur001 with hold for
就可以執行了。