日期:2014-05-16  浏览次数:20654 次

初用Mysql,大家帮我看看这个存储过程有语法错误么?
CREATE   DEFINER=`root`@`localhost`   PROCEDURE   `getInfo`(
in   sip   varchar(50),
in   dip   varchar(50),
out   Zgjcs   int,
out   Zbgjcs   int,
out   Gjcs   int,
out   Zfsbs   int,
out   Zfssjl   int,
out   Zjsbs   int,
out   Zjssjl   int,
out   Fsbs   int,
out   Fssjl   int
)
BEGIN
    select   Zgjcs   =   ((select   count(*)   from   Program1   where     sip=sip   )   +   (select   count(*)     from   Program2   where     sip=sip));
    select   Zbgjcs   =   ((select   count(*)     from   Program1   where     dip=dip)   +   (select   count(*)     from   Program2   where     dip=dip));
    select   Gjcs   =   ((select   count(*)   from   Program1   where     sip=sip   and   dip=dip)   +     (select   count(*)     from   Program2   where     sip=sip   and   dip=dip));
    select   Zfsbs   =   (sum(a.trigger_times)+sum(b.repeat1)),   Zfssjl   =   sum(b.traffic)   from   Program1   a,   Program2   b   where   a.sip=sip   or   b.sip=sip;
    select   Zjsbs   =   (sum(a.trigger_times)+sum(b.repeat1)),   Zjssjl   =   sum(b.traffic)   from   Program1   a,   Program2   b   where   a.dip=dip   or   b.dip=dip;
    select   Fsbs   =     (sum(a.trigger_times)+sum(b.repeat1)),   Fssjl   =   sum(b.traffic)     from   Program1   a,   Program2   b   where   (a.sip=sip   and   a.dip=dip)   or   (b.sip=sip   and   b.dip=dip);
END;


------解决方案--------------------
动态语句要用预处理来做。
------解决方案--------------------
一堆SELECT,到底是要做什麽用?
------解决方案--------------------
select 换成 set