我有一个查询,它将存储的查询作为表格的文本,然后通过user参数运行特定的查询。 (在这种情况下,参数是名称) 查询是:
CREATE OR REPLACE FUNCTION public.event_test(strt timestamp without time zone, ende timestamp without time zone, name character varying, world integer, type character varying, type_value integer)
RETURNS TABLE(user_code character varying, user_nick character varying, alliance character varying, delta bigint)
LANGUAGE plpgsql
AS $function$
DECLARE
stmt text;
BEGIN
select query into stmt from events_queries where event_name=name ;
return query execute stmt using strt,ende,world,type,type_value ;
END
$function$
当我运行它时,我收到错误:
列strt不存在
即使我使用using
执行。
该函数正确使用参数name
,如果不使用执行,我编写查询本身也可以。
我看过这个类似的问题: Pl/pgSQL there is no parameter $1 in EXECUTE statement
但问题仍然存在。
任何想法如何在我的文本中传递参数?