I am trying to create a new function (search function), but I get syntax error at or near "select" and I don't know why...
create or replace function searchCategories(recherche text)
returns setof categories as $$
select *
from categories
where to_tsvector(titre_fr || ' ' || titre_cn)
@@ to_tsquery(recherche);
$$ language plpgsql;
g
garyaustin
02/09/2022, 12:09 AM
try putting a begin and end before select and before $$
j
joshcowan25
02/09/2022, 1:43 AM
Thank you!
joshcowan25
02/09/2022, 1:52 AM
Would you happen to know why I get ' type " " does not exist' on some queries?
g
garyaustin
02/09/2022, 2:01 AM
not without more info... normally setof must exactly match the table structure, but with * on your select not sure why that would be an issue.