UPDATE a_person p
   SET p.avatar = nvl2(mobi_number, SUBSTR(utl_encode.base64_decode(hextoraw(mobi_number)),-10), email)
 WHERE p.avatar IS NULL;

解决方案 »

  1.   

    create or replace procedure you_pro_name(RetMemo out varchar2 --返回信息
                                                     )
    is
     v_nicheng    varchar2(20);--id 为a_person主键
     v_count number;
     cursor c_find is
     select * from a_person;
     cc c_find%rowtype;
    begin
      RetMemo :='';
      v_count :=0;
      open c_find;
          loop
              fetch c_find into cc;
              exit when c_find%notfound;
              if cc.nicheng is null then
               if cc.phone is null then
                 v_nicheng :=cc.mail;
                 else
                   v_nicheng :=substr(utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw(cc.phone))),-10);
                  end if; 
                     update a_person set nicheng=v_nicheng where id = cc.id;
                     commit;    
                     v_count :=v_count+1;    
                       end if;       
             end loop;
             close c_find;
             RetMemo:=RetMemo||'更新了'||v_count||'条数据';
    exception
       when others then
         begin
          rollback;
          RetMemo := sqlerrm;
          return;
         end;
    end;差不多是这个样子吧
      

  2.   

    想修改就用1楼,想查询就把那句改成select