x_iaoyuer 发表于 2009-3-6 17:50:30

mysql 存储过程错误

drop procedure if exists sp_ylc;
create procedure sp_ylc()
begin
   DECLARE @userid INT;   
   DECLARE @opsid INT;
   DECLARE @cunm INT;
   DECLARE @moduleid INT;   
   DECLARE @mduname VARCHAR(200);
   DECLARE @i INT;
   DECLARE @content VARCHAR(500);
   DECLARE @time datetime ;
   DECLARE @objectID INT ;
   DECLARE @copt INT;
   DECLARE @copt INT;
   DECLARE @objlist VARCHAR(500);
   DECLARE @operarry1 VARCHAR(500);
   DECLARE @operarry2 VARCHAR(500);
   DECLARE @content0 VARCHAR(500);
   DECLARE @contentp VARCHAR(500);
   DECLARE @ctime datetime ;
   DECLARE @ipd INT;
   DECLARE @ptimes datetime;
   DECLARE @stimo datetime;
   DECLARE @ent VARCHAR(500);
   DECLARE @iupoi INT;
   DECLARE @ipok INT;
Select @userid = I_userID,@opsid=I_operationID,@cunm=count(*) from space_operation_record where status<>0 group by I_userID,I_operationID;
while @cunm > 0 do
   select @cunm = @cunm -1;
    Select @moduleid=I_moduleID from space_operation where status<>0 and ID=@opid;
    if @moduleid > 0 then
      Select @mduname=Nvc_name from space_module where status<>0 and ID=@moduleid;
      if @mduname > 0 then
      select@i=0;
         Select @content=Nvc_content,@id=ID,@time=createtime,@objectID=I_objectID,@copt=count(*) from space_operation_record where status<>0 and I_operationID=opid and I_userID=userid;
         if copt > 0 then
            if @mduname = '日志' then
               while @copt > 0 do
                select @copt = @copt -1;
            INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,Createtime) VALUES ('@id','@userid','@content','@time',now());
               end while;
            else
                while @Copt > 0 do
             if @i > 5 then
            break;
             end if;
             select @objlist= CONCAT(@objectID,CONCAT(@objectID,','));
            select@operarry1 = substring_index(@content,'|',1);
            select@operarry2 = substring_index(@content,'|',-1);
            select@content0 =CONCAT(@operarry2,SPACE(1));
            select @copt = @copt -1;
               select @i = @i + 1;
                end while;
               select @objlist = substring(@objlist,'-1');
                if @content0 is null then
                  select @contentp= CONCAT(@operarry1,@content0);
                  Select @ctime=createtime,@ipd=ID from space_operation_record where status<>0 and I_operationID=@opid order by createtime desc limit 0,1;
                  if @ipd > 0 then
                  INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,Createtime,Nvc_objlist) VALUES('@ipd','@userid','@contentp','@ctime',now(),'@objlist');
                  end if;
                end if;
            end if;
         end if;
      end if;   
      
    end if;
end while;
UPDATE space_operation_play SET status=0;
UPDATE space_operation_display SET status=0;
Select @ptimes=createtime from space_operation_stat where status<>0 order by createtime desc limit 0,1;
if @ptimes > 0 then
Select @stimo=D_stattime,@ent=Nvc_content,@iupoi=I_userID,@ipok=ID from space_operation_stat where status<>0and createtime='@ptimes'order by D_stattime desc limit 0,30;
   if @stimo > 0 then
    INSERT INTO space_operation_play(I_statID,Nvc_content,D_stattime,I_userID,Createtime) VALUES ('@ipok','@ent','@stimo',now());
   end if;
end if;

end

x_iaoyuer 发表于 2009-3-6 17:51:48

请高手帮我看一下哪里有问题,谢谢了 我对mysql 的存储过程实在是不懂谢谢各位大虾了

x_iaoyuer 发表于 2009-3-6 17:52:09

自己顶下

kider 发表于 2009-3-6 19:24:53

提示什么错?

only_dang 发表于 2009-3-17 11:56:03

你的数据库表是什么 ,提示的错误是什么?不然这怎么找
页: [1]
查看完整版本: mysql 存储过程错误