我有一个函数如下:
CREATE FUNCTION public.my_func(...)
RETURNS TABLE(a integer, b timestamp without time zone, c timestamp without time zone) AS
$BODY$
BEGIN
create temporary table t1 as
select ....
RETURN QUERY
WITH RECURSIVE x AS ( working with t1 ..... ) SELECT x.a, x.b, x.c where ....;
当我将其称为“select my_func(1, 2, 3)”时,它会在单个列中返回数据:
result
-----------
(32, "7-dec-2016", "3-mar-2017")
我希望它在 3 个单独的列中返回它。怎么办?
最佳答案
当您调用函数 SELECT my_func(1, 2, 3)
时,您的结果将记录在一个字段中。你需要运行:
SELECT * FROM my_func(1, 2, 3);
关于sql - 函数返回单个列中的数据,而不是 3 个单独的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42172432/