Can a stored procedure/function return a table?(存储过程/函数可以返回表吗?)
问题描述
MySql 存储过程/函数能否在不使用临时表的情况下返回表?
Can a MySql stored procedure / function return a table without the use of temp table?
创建以下过程
CREATE PROCEDURE database.getExamples()
SELECT * FROM examples;
然后用
CALL database.getExamples()
显示示例表 - 正如预期的那样 - 但以下似乎不可能:
displays the example table - just as expected - but the following doesn't seem to be possible:
SELECT * FROM CALL database.getExamples()
是否可以从存储过程/函数返回查询结果表,如果可以,如何返回?
Is it possible at all to return a query result table from a stored procedure / function, and if so - how?
推荐答案
就目前而言,这是不可能的.
As for now, this is not possible.
这是文档 关于 FROM 子句中可能使用的内容:
Here is the documentation on what may be used in the FROM clause:
table_references:
table_reference [, table_reference] ...
table_reference:
table_factor
| join_table
table_factor:
tbl_name [[AS] alias] [index_hint)]
| table_subquery [AS] alias
| ( table_references )
| { OJ table_reference LEFT OUTER JOIN table_reference
ON conditional_expr }
join_table:
table_reference [INNER | CROSS] JOIN table_factor [join_condition]
| table_reference STRAIGHT_JOIN table_factor
| table_reference STRAIGHT_JOIN table_factor ON conditional_expr
| table_reference {LEFT|RIGHT} [OUTER] JOIN table_reference join_condition
| table_reference NATURAL [{LEFT|RIGHT} [OUTER]] JOIN table_factor
join_condition:
ON conditional_expr
| USING (column_list)
index_hint:
USE {INDEX|KEY} [FOR JOIN] (index_list)
| IGNORE {INDEX|KEY} [FOR JOIN] (index_list)
| FORCE {INDEX|KEY} [FOR JOIN] (index_list)
index_list:
index_name [, index_name] ...
如您所见,存储过程不在此列表中.
As you can see, stored procedures are not in this list.
这篇关于存储过程/函数可以返回表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:存储过程/函数可以返回表吗?
基础教程推荐
- oracle区分大小写的原因? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
