I tried in Postgres 9.3
CREATE OR REPLACE FUNCTION f_tsd(koakuupav date, kolkuupaev date)
RETURNS TABLE (
isikukood int
) AS
$func$
select 1 where current_date between koakuupaev and kolkuupaev
$func$ LANGUAGE sql STABLE;
but got error
ERROR: column "koakuupaev" does not exist
In plpgsql it causes same error at run time:
CREATE OR REPLACE FUNCTION f_tsd(koakuupav date, kolkuupaev date)
RETURNS TABLE (
isikukood int
) AS
$func$
BEGIN
RETURN QUERY select 1 where current_date between koakuupaev and kolkuupaev;
end; $func$ LANGUAGE plpgsql stable;
select * from f_tsd(current_date, current_date)
How to pass parameters to where clause in function in Postgres ? According to docs named parameters must work.
integeror cast the1to a numeric value (I guess that's the problem with your second version)