TA的每日心情 | 开心 2021-12-13 21:45 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
|
发表于 2013-12-17 11:49:11
|
显示全部楼层
create or replace procedure pro_set_nick_name
(
pid in a_person.pid%type --主键id
)
is
v_nickName a_person.nick_name%type; --昵称
v_phone a_person.phone%type; --手机号码
v_email a_person.email%type; --邮箱
v_pid a_person.pid%type:=pid; --主键id
begin
--找到昵称
select a.nick_name into v_nickName from a_person a where a.pid = v_pid;
--昵称为空
if v_nickName is null then
--找到电话号码
select a.phone into v_phone from a_person a where a.pid = v_pid;
--电话不为空
if v_phone is not null then
--base64解密
v_phone := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw(v_phone)));
--截取后10位
v_phone := substr(v_phone,length(v_phone-10),10);
--更新
update a_person a set a.nick_name = v_phone;
--电话为空
elsif v_phone is null then
--获取邮箱
select a.email into v_email from a_person a where a.pid = v_pid;
--更新
update a_person a set a.nick_name = v_email;
end if;
end if;
end; |
|