I want to create a function in Postgres along the lines of this:
CREATE OR REPLACE FUNCTION public.getAvailableForms (
get_form_names TEXT[]
) RETURNS TABLE (
id INTEGER,
name TEXT,
location TEXT,
created TIMESTAMP
) AS $$
BEGIN
RETURN QUERY
SELECT *
FROM form
WHERE form.name IN get_form_names;
END;
$$ LANGUAGE plpgsql
SECURITY DEFINER;
However, it tells me that WHERE form.name IN get_form_names is syntactically incorrect.
I can't find any documentation on how to use array variables in a postgres function call.
Anyway, is it possible to use an array value passed as a function argument in a WHERE ... IN?
select *, then you don't need to declare the table as the output. Instead you could doRETURNS SETOF form ASinstead ofRETURNS TABLE ( ... ) AS. I realize this may be a primitive example to demonstrate your issue, but if you really are literally returning every field from the "form" table, this might be helpful.