create procedure up_generatePK(@corp varchar(50),@rst varchar(50) output)
as
begin
declare @old varchar(14)='10000000000000'
declare @c char(1)
declare @j bit=1
declare @i int=1
declare @str varchar(100)='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
select @old=idnumber from pub_oid where pk_corp = @corp
set @old=reverse(@old)
while @j='true'
begin
set @c=substring(@old,@i,1)
set @c=substring(@str,charindex(@c,@str)+1,1)
if isnull(@c,'')=''
begin
set @c=substring(@str,1,1)
set @j='true'
end
else
begin
set @j='false'
end
set @old=stuff(@old,@i,1,@c)
set @i=@i+1
end
set @rst =@corp + 'AA' + reverse(@old)
update pub_oid set idnumber = @rst where pk_corp = @corp
IF @@ROWCOUNT = 0
begin
insert into pub_oid (dr, idnumber, pk_corp) values (0, @rst, @corp)
end
end
用友NC65生成主键值
于 2023-10-13 13:45:14 首次发布