- 论坛徽章:
- 0
|
我写的存储过程如下:
- CREATE PROCEDURE `cate_getRoute`(_id INTEGER(4))
- BEGIN
- DECLARE x_path char(255);
- select `path` from `cate` where `id`=_id into x_path ;
- select `id`,`name` from `cate` where cate.id in (x_path);
- END
复制代码
其中path字段的格式如:0,15,16。该存储过程的作用是先从cate表中根据_id参数取出path的值,并赋给x_path,然后在从cate表中查询出所有id在x_path中的行,执行起来虽然没报错,但没取出任何数据:如下
- mysql> call cate_getRoute(15);
- Empty set
- Query OK, 0 rows affected
复制代码
请教这是什么原因?存储过程中x_path变量的问题?
直接在CONSOLE运行sql正常,如下:
- mysql> select `id`,`name` from `cate` where cate.id in (0,15,16) ;
- +-------+------+
- | id | name |
- +-------+------+
- | 00015 | fdsf |
- | 00016 | fdsf |
- +-------+------+
- 2 rows in set
复制代码
正常
- mysql> select `path` from `cate` where `id`=15;
- +------+
- | path |
- +------+
- | 0,15 |
- +------+
- 1 row in set
复制代码
正常
[ 本帖最后由 暖暖咖啡 于 2007-1-9 17:34 编辑 ] |
|