I have a function that takes in an argument which is meant to be passed to a RETURN QUERY and the data is fed in from an underlying view.
Now I get zero rows when I execute the function but when I run the select statement on it's own I get results.
So part of me thinks that the
function parameter is not being read at all. Any help/suggestions is appreciated.
create or replace function my_trans(IN inid character)
RETURNS TABLE(
a_date timestamp without time zone,
pnt_sys character,
nval numeric,
pnt_type character,
gpid integer)
as $$
#variable_conflict use_column
BEGIN
RETURN QUERY
SELECT
BORN_DATE,
MY_SYSTEM,
MY_VALUE,
MY_TYPE,
MY_PAY_ID
FROM vw_psr where nid ~* '$1';
end;
$$ language plpgsql
(IN inid character varying)or(IN inid text), supposing you want a string argument.$1) -- it will mean literally the string'$1'(you can use the identifierinidtoo because you named your parameter). Also note that in its current state aLANGUAGE sqlfunction might be better suited for your needs.