oracle函数

做一个主键id,他为序列生成,而且其必须为7为数字,如果不太够,则使用0补充!

create or replace function fn_get_Personid -- 个人信息采集:获取7位的id值
(
id in varchar2 -- 无用
) 
return  varchar2 is
 t_id varchar2(10); -- 要返回的信息Id
begin
    
select SEQ_HR_PERSON_ID.Nextval 
into t_id
 from dual; -- 查询序列
 
 if length(t_id)=6 then
 t_id:='0'||t_id;
 elsif length(t_id)=5 then
 t_id:='00'||t_id;
 elsif length(t_id)=4 then
 t_id:='000'||t_id;
 elsif length(t_id)=3 then
 t_id:='0000'||t_id;
 elsif length(t_id)=2 then
 t_id:='00000'||t_id;
 elsif length(t_id)=1 then
 t_id:='000000'||t_id;
 end if;
 
  return(t_id); -- 返回处理后的数据
end fn_get_Personid;

 

注意使用pl/sql中自动自动生成的工具!

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值