Shi*_*are 6 postgresql graphql hasura
我在 hasura 中创建了自定义 sql 函数并跟踪它。但需要在“ RETURNS SETOF <table-name>”中写入表名(参考: https: //docs.hasura.io/1.0/graphql/manual/schema/custom-functions.html)。在这里,我无法创建具有与函数返回列相同的架构的新表。我有很多函数要创建,所以我想要一个解决方案,我可以在其中创建一个返回 SETOF 而不带表名的函数。
即使在 hasura 函数中也无法返回虚拟表(即RETURNS Table(column1 text, column2 text, column3 text))
我尝试了“创建类型”并将其用作
CREATE TYPE temp_type AS
(column1 text, column2 text, column3 text
);
Run Code Online (Sandbox Code Playgroud)
但没有工作并给出以下错误:
“无法跟踪函数“my_function”,因为该函数不返回 SETOF 表”
对此有什么解决办法吗?
这是我的功能
CREATE FUNCTION my_function(fromDate text, toDate text)
RETURNS SETOF <table-name> AS $$
// My function logic here
// which returns column1, column2, column3
$$ LANGUAGE sql STABLE;
Run Code Online (Sandbox Code Playgroud)