ITPub博客

首页 > 数据库 > Oracle > 函数1

函数1

原创 Oracle 作者:simkyo 时间:2013-11-28 09:21:54 0 删除 编辑
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/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: split拆分
下一篇: 过程1
请登录后发表评论 登录
全部评论

注册时间:2013-06-20

  • 博文量
    193
  • 访问量
    165517