hasura-查询没有结果数据的目的地
在Hasura中,我正在尝试编写基于PLPGSQL的功能,该功能应返回t_documents。该函数应基于应运行适当的SQL的参数值接受各种可选参数(使用条件检查)并返回记录。这是我的目标。
我从没有参数的简单函数开始,在Hasura中成功创建和跟踪的功能,但是当尝试查询时,它会投掷“查询没有结果数据的目的地”
任何帮助实现目标的帮助是高度赞赏
CREATE OR REPLACE FUNCTION dms.fngetdocs()
RETURNS SETOF dms.t_documents
LANGUAGE plpgsql
STABLE
AS $function$
BEGIN
SELECT *
FROM dms.t_documents;
END;
$function$
In Hasura, I'm trying write a plpgsql based function which should return the t_documents. The function should accept various optional arguments, based on the argument values it should run appropriate SQL (using IF conditional checks) and return the records. This is my goal.
I've started with simple function with no arguments, the function created and tracked successfully in Hasura, however when try to query it throws "query has no destination for result data"
Any help to achieve the goal is highly appreciated
CREATE OR REPLACE FUNCTION dms.fngetdocs()
RETURNS SETOF dms.t_documents
LANGUAGE plpgsql
STABLE
AS $function$
BEGIN
SELECT *
FROM dms.t_documents;
END;
$function$
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个sql语句返回行(例如
选择
,但in
带有返回
等)必须有一个目标数据的目标。这就是错误消息告诉您的。分配变量或返回到呼叫者。对于丢弃结果,请使用perrive
而不是选择
。请参阅://stackoverflow.com/questions/10115806/select-erect-or-perform-in-a-pl-pgsql-function/10117015#10117015"> select 行。您的PL/PGSQL函数将像这样工作:
请参阅:
当然几乎没有任何意义。而不是调用该函数,而是直接使用
select *从dms.t_documents;
直接使用。或使用更简单的SQL函数,其中
选择
的结果自动返回:请参阅有关添加
并行安全
的手册。Every SQL statement returning rows (like
SELECT
, but alsoINSERT
withRETURNING
etc.) must have a target for the resulting data. That's what the error message tells you. Either assign variables or return to the caller. To discard results instead, usePERFORM
instead ofSELECT
. See:But you obviously want to return rows. Your PL/pgSQL function would work like this:
See:
Makes very little sense, of course. Instead of calling that function you would just use
SELECT * FROM dms.t_documents;
directly.Or use a simpler SQL function, where the result of a
SELECT
is returned automatically:See the manual about the added
PARALLEL SAFE
.