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;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12961536/viewspace-1061344/
,如需转载,请注明出处,否则将追究法律责任。