Filter a SELECT query with predicates passed as single hstore value
1
vote
1
answer
171
views
For an API I am building I am supposed to write a function with a single
hstore
argument containing colname => value
pairs so that queries may be filtered with a WHERE
clause including an indefinite amount of subclauses. I currently have the following function definition (not a MWE):
CREATE OR REPLACE FUNCTION api.func( conds HSTORE )
RETURNS TABLE (LIKE api.tab) AS
$$
BEGIN
RETURN QUERY
SELECT *
FROM api.tab
WHERE -- conds here
LIMIT 25 ;
END;
$$ LANGUAGE plpgsql;
I am not really sure how to continue. Could someone please give me a hint?
Asked by eslukas
(111 rep)
Aug 8, 2022, 11:45 AM
Last activity: Jul 18, 2025, 09:06 PM
Last activity: Jul 18, 2025, 09:06 PM