引用其他数据库中的存储过程?

时间:2023-01-14 23:52:10

From a stored procedure or function in a given MySQL database, is it possible to reference a stored procedure or function in another MySQL database, as follows?

从给定MySQL数据库中的存储过程或函数,是否可以在另一个MySQL数据库中引用存储过程或函数,如下所示?

SELECT 
    some_table.field1,
    some_table.field2,
    another_database.STORED_PROCEDURE(arg), 
    ...
FROM ...
WHERE ...

1 个解决方案

#1


Yes, you can, just prefix them with the database name.

是的,您可以使用数据库名称作为前缀。

BTW: What you're showing is a stored function. For stored procedures you must use CALL and they can't return a value.

顺便说一句:你所展示的是一个存储功能。对于存储过程,您必须使用CALL,它们不能返回值。

#1


Yes, you can, just prefix them with the database name.

是的,您可以使用数据库名称作为前缀。

BTW: What you're showing is a stored function. For stored procedures you must use CALL and they can't return a value.

顺便说一句:你所展示的是一个存储功能。对于存储过程,您必须使用CALL,它们不能返回值。