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;