mysql建立存储过程出错

#建立存储过程p_dir_infoDELIMITER$$DROPPROCEDUREIFEXISTSdisk.p_dir_info$$CREATEDEFINER=root@... # 建立存储过程p_dir_info
DELIMITER $$

DROP PROCEDURE IF EXISTS disk.p_dir_info$$
CREATE DEFINER=root@localhost PROCEDURE disk.p_dir_info(in user varchar(20), in parent_path varchar(255))
BEGIN
select * from
(select d.user, d.path , d.parent_path, d.dir, d.create_time ,
(case isnull(sum(f.count)) when true then 0 else sum(f.count) end) as count,
(case isnull(sum(f.size)) when true then 0 else sum(f.size) end) as size
from t_directories d left join
(select path, count(file) as count, sum(size) as size from t_files group by path) f on instr(f.path, d.path) = 1
where d.user=user and d.parent_path=parent_path group by path) dir order by create_time;
END $$

DELIMITER ;

在Navicat中运行出现如下错误:
Query OK, 0 rows affected

1064 - 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 'PROCEDURE disk.p_dir_info(in user varchar(20), in parent_path varchar(255))
BE' at line 1

请高手帮忙解决下,十分感谢
展开
 我来答
华夏日长兴
2009-09-02 · TA获得超过9592个赞
知道大有可为答主
回答量:6305
采纳率:85%
帮助的人:3734万
展开全部
CREATE PROCEDURE p_dir_info (in user varchar(20), in parent_path varchar(255))
BEGIN
select * from
(select d.user, d.path , d.parent_path, d.dir, d.create_time ,
(case isnull(sum(f.count)) when true then 0 else sum(f.count) end) as count,
(case isnull(sum(f.size)) when true then 0 else sum(f.size) end) as size
from t_directories d left join
(select path, count(file) as count, sum(size) as size from t_files group by path) f on instr(f.path, d.path) = 1
where d.user=user and d.parent_path=parent_path group by path) dir order by create_time;
END;

仅保留这些代码我是实的能用
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式