56,677
社区成员
发帖
与我相关
我的任务
分享
top: BEGIN
DECLARE tableid INTEGER;
DECLARE aliasint INTEGER;
DECLARE count_setup INTEGER;
DECLARE alias_long varchar(400);
DECLARE alias VARCHAR(1) DEFAULT 'A';
DECLARE errorcode INTEGER DEFAULT 0 ;
if ( ta_abbre is null ) then return ( null ) ;
end if;
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET errorcode = 1 ;
select table_id into tableid from tw_table where table_abbre=ta_abbre;
END;
if (tableid is null ) then return ( null );
end if;
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET errorcode = 1 ;
select group_concat(right(table_alias,1)) into alias_long from dc_ordermaptable where table_id=tableid and is_hang=0 group by table_id;
END;
if ( alias_long is null ) then return ( concat( ta_abbre , 'A' ));
else
set aliasint=65 ;
set alias = char( aliasint );
flag: while aliasint <=69 and aliasint >=65 do
if ( POSITION( alias IN alias_long) = 0 ) then
leave flag;
end if;
set aliasint = aliasint +1 ;
set alias = char( aliasint );
end while;
end if;
if ( ascii ( alias )> 69 ) then return ( null ) ;
end if;
return ( concat( ta_abbre , alias ));END