mysql中写了一段存储过程,举个例子,我数据库中有两个值一个是“001”,另一个是“餐饮软件名”,我分别传这两个值,其中“001”返回的值‘001A’,而“餐饮软件名”返回的是一个“null”,现在想请教大家,怎样让我的“餐饮软件名”返回的值是“餐饮软件名A”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 ));ENDmysql存储
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 ));ENDmysql存储
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货