I have a requirement to search for the strings starting with char provided by user. I am using a postgresql function and returning SETOF-
CREATE OR REPLACE FUNCTION public._A1_loc_search15(in_pattern character varying)
RETURNS setof character varying
AS
$$
SELECT coord FROM table1 WHERE loc_lb ~* '^in_pattern';
$$
LANGUAGE sql;
SELECT public._A1_loc_search15('A');
While the select query runs fine if hard coded '^A' is used, with user input it's not working. Any insight on how to use it correctly would help. Thanks.