I have this postgresql function
CREATE OR REPLACE FUNCTION sp_select_test(_id bigint)
RETURNS void AS
$BODY$
BEGIN
copy (select sub.id
from (
SELECT id FROM sim s where id = _id) sub) TO '/tmp/results.tsv';
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION sp_select_test(bigint)
OWNER TO postgres;
When I run
select * from sp_select_test(264);
I get error - column "_id" does not exist
If I replace the variable _id in the function with a value say 264, the function works. That is if instead of id = _id I use id = 264
Any reason why the function is failing?