mysql存储过程问题??

hongming271 2013-03-15 05:35:49
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 ));END
...全文
45 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
rucypli 2013-03-15
  • 打赏
  • 举报
回复
在select concat执行前先执行set names gbk;

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧