select *
from v_customer_num
where customer_code in
(
select * from
(with test as (select customer_code c from t_run_activity_plan_customers r where r.activity_code='act201309060000000889')
select substr(t.ca,instr(t.ca, ',', 1, c.lv) + 1,instr(t.ca, ',', 1, c.lv + 1) - (instr(t.ca, ',', 1, c.lv) + 1)) AS c
from (select ',' || c || ',' AS ca,length(c || ',') - nvl(length(REPLACE(c, ',')), 0) AS cnt FROM test) t,
(select LEVEL lv from dual CONNECT BY LEVEL <= 100) c where c.lv <= t.cnt)
where c is not null
);
-- 根据游标取不同的值
create or replace function f_zbn(o_flag out number) return int is
v_tmp number;
v_a t_test.content1%type;
cursor cur_1 is select t.content1 from t_test t;
ERRCODE INT; -- ORACLE 错误代码
ERRMSG VARCHAR2(200); -- ORACLE 错误描述
begin
open cur_1;
fetch cur_1 into v_a;
while cur_1%found loop
select trunc(dbms_random.value(1, 97)) into v_tmp from dual;
update t_test t
set t.content1 =
(select a.msg from t_dz a where a.rn = v_tmp)
where t.content1 = v_a;
commit;
fetch cur_1 into v_a;
end loop;
close cur_1;
o_flag := 0;
return 0;
exception
WHEN OTHERS THEN
o_flag := 1;
return 1;
ERRCODE := SQLCODE;
ERRMSG := SUBSTR(SQLERRM, 1, 200);
dbms_output.put_line(ERRCODE);
dbms_output.put_line(ERRMSG);
end f_zbn;
MERGE INTO t_ws_individual_total_b a
USING t_sp_dsj_b b
ON (a.USER_PHONE = b.USER_PHONE)
WHEN MATCHED THEN
UPDATE SET a.sp_dsj=
b.content1||b.content2||b.content3||b.content4||b.content5||b.content6||b.content7||b.content8||b.content9||b.content10
WHEN NOT MATCHED THEN
INSERT(a.USER_PHONE,SP_DSJ) VALUES
(b.USER_PHONE,b.content1||b.content2||b.content3||b.content4||b.content5||b.content6||b.content7||b.content8||b.content9||b.content10);
commit;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12961536/viewspace-1061230/
,如需转载,请注明出处,否则将追究法律责任。