qq_32504001
qq_32504001
2017-09-08 06:58

存储过程 使用for循环更新执行 报错 ORA-06550

  • cursor
  • 存储

create or replace procedure test is
Cursor C_EMP is
select * from CST_TW_RECORD where GRANT_STATE = '0' and CLEAN_STATE = '3' ;
C_ROW C_EMP%ROWTYPE; --定义游标变量,该变量的类型为基于游标C_EMP的记录

begin
--For 循环

FOR C_ROW IN C_EMP LOOP
-- 更新清洗记录表
update CST_TW_RECORD set GRANT_STATE = 1,GRANT_FIRST_DATE=sysdate,GRANT_DATE=sysdate,SELLER_ID = 2012999991,GRANT_REMARK = 11 where CUST_ID=C_ROW.CUST_ID ;
--更新客户表
update CST_CUSTOMER set APP_DATE = sysdate,PAST_DATE = sysdate,SELLER_ID = 2012999991,SELLER_DEPT_ID = 0001
where CUST_ID=C_ROW.CUST_ID ;
--踢出客户
UPDATE CST_CUSTOMER_EXTEND SET PUB_STATE = 1 WHERE CUST_ID =C_ROW.CUST_ID ;
end;
end LOOP;
end test;

--执行存储过程
begin
execute test ;
end;

图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答

为你推荐