MYSQL存储过程,实在无法,求解释??
本帖最后由 business124 于 2012-6-18 10:41 编辑<P> BEGIN
declare Pmax int; -- 记录表中最大ID
declare Pmin int; -- 记录表中最小ID
declare PID smallint(6);-- 记录当前统计Pack_ID,用于与总表userservicerelation联系,统计Pack_ID的人气
delete from packcollectionrank;-- 清空表
insert into packcollectionrank(Pack_ID) select distinct Pack_ID from products ;-- 插入所有Pack_ID到统计表packcollectionrank</P>
<P> select MAX(ID) into Pmax from packcollectionrank;
select MIN(ID) into Pmin from packcollectionrank;</P>
<P> while Pmin<=Pmax do-- 插入所有Pack_ID的人气,没订阅默认为0
select Pack_ID into PID from tdxtb_packcollectionrank where ID=Pmin;</P>
<P> set @sql1=CONCAT("UPDATE packcollectionrank SET Collection_count=(SELECT COUNT(*) FROM userservicerelation WHERE Pack_ID=",PID," AND Relation_Status=6) WHERE Pack_ID=",PID,";");
PREPARE rankpack1 FROM @sql1;
EXECUTE rankpack1; </P>
<P> set Pmin=Pmin+1;
end while;
-- 插入
END
</P>本机执行:时间: 0.250ms
Procedure executed successfully
受影响的行: 1
换机子执行:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare Pmax int;
MYSQLSELECT version();后版本都是5.5.17
这怎么解释,求高人指点!!
能把整个存储过程贴出来,还有完整的错误信息。。 hm3030 发表于 2012-6-19 11:11 static/image/common/back.gif
能把整个存储过程贴出来,还有完整的错误信息。。
已解决,对方犯了个小错误,汗~~一上午。
页:
[1]