日期:2014-05-17  浏览次数:20837 次

写个存储过程,不知道怎么写
让a_person表中昵称为空的用户,(字段你们可以见名之意的定义就好)用他的手机号码后10位作为昵称,如果用户手机号为空,则用用户的邮箱作为昵称,其中邮箱是不能为空的,而且手机号码是用base64加密的,需要解密,这个存储过程怎么写?

------解决方案--------------------
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;

------解决方案--------------------
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&nb