vip_update_sql varchar2(255); ---更新操作语句
vip_reback_sql varchar2(255); ---将以前的还原的语句
vip_users varchar2(32); ---这次需要更新的用户
select DEST_TERMINAL from masc_log_publish_message
where publish_time<trunc(sysdate-10)
and publish_time>=trunc(sysdate-17)
and DELIVERY_STATUS_CODE=21000
group by DEST_TERMINAL
having count(*)>7;
vip_reback_sql := 'update ibs_customer set rank=0 where rank=1';
execute immediate vip_reback_sql;
commit;
open vip_customer;
loop
fetch vip_customer
into vip_users;
exit when vip_customer%NOTFOUND;
vip_update_sql := 'update ibs_customer set rank=1 where name = '''||vip_users||'''';
execute immediate vip_update_sql;
commit;
<<nextlable>>
null;
end loop;
close vip_customer;
end vip_update;
/
PL/SQL中处理单引号
例:
declare
vc_name varchar2(100) :='shikai';
vc_str varchar2(100) ;
begin
dbms_output.put_line('hello, ' || 'shikai'); --输出hello, shikai
dbms_output.put_line('hello, ' || vc_name); --输出hello, shikai
dbms_output.put_line('hello, ' || '''shikai'''); --输出hello, 'shikai'
dbms_output.put_line('hello, ''' || 'shikai'||''''); --输出hello, 'shikai'
dbms_output.put_line('hello, ''' || vc_name||''''); --输出hello, 'shikai'
end;