phpmyadmin运行mysql存储过程但没有输出

时间:2021-04-13 10:12:59

I write a very simple stored procedure as below:

我写了一个非常简单的存储过程如下:

DROP PROCEDURE IF EXISTS GetAllTours;

DELIMITER // 

CREATE PROCEDURE GetAllTours() 

BEGIN 

SELECT * FROM tours; 

END // 

DELIMITER ;

When I use

我用的时候

CALL GetAllTours(); 

from SQL query to run this procedure, there is no output.

从SQL查询运行此程序,没有输出。

But if I run from >>Routines>>Execute, the same procedure, there will have output successfully.

但是如果我从>> Routines >> Execute运行,同样的程序,就会有输出成功。

Can anybody tell me how to run from SQL query and get the results?

任何人都可以告诉我如何从SQL查询运行并获得结果?

2 个解决方案

#1


1  

You can just use this query: CALL GetAllTours

您可以使用此查询:CALL GetAllTours

#2


-1  

First of all, i think you are trying to create a view. Take a look here: http://dev.mysql.com/doc/refman/5.0/en/create-view.html

首先,我认为你正在尝试创建一个视图。看看这里:http://dev.mysql.com/doc/refman/5.0/en/create-view.html

mysql> CREATE VIEW GetAllActiveTours AS SELECT * FROM tours where active=1;
mysql> select * from GetAllActiveTours;

for returning data from a procedure use an OUT parameter. http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html

从过程返回数据使用OUT参数。 http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html

example from link above:

上面的链接示例:

mysql> CREATE PROCEDURE simpleproc (OUT param1 INT)
    -> BEGIN
    ->   SELECT COUNT(*) INTO param1 FROM t;
    -> END//
mysql> CALL simpleproc(@a);
mysql> SELECT @a;

#1


1  

You can just use this query: CALL GetAllTours

您可以使用此查询:CALL GetAllTours

#2


-1  

First of all, i think you are trying to create a view. Take a look here: http://dev.mysql.com/doc/refman/5.0/en/create-view.html

首先,我认为你正在尝试创建一个视图。看看这里:http://dev.mysql.com/doc/refman/5.0/en/create-view.html

mysql> CREATE VIEW GetAllActiveTours AS SELECT * FROM tours where active=1;
mysql> select * from GetAllActiveTours;

for returning data from a procedure use an OUT parameter. http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html

从过程返回数据使用OUT参数。 http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html

example from link above:

上面的链接示例:

mysql> CREATE PROCEDURE simpleproc (OUT param1 INT)
    -> BEGIN
    ->   SELECT COUNT(*) INTO param1 FROM t;
    -> END//
mysql> CALL simpleproc(@a);
mysql> SELECT @a;