I try to create a dynamic function that exports data specific ids controlled by a for, but when I run the function it shows me the error that there is no column i ,
I would like to concatenate the variable i with the name of the output file
CREATE OR REPLACE FUNCTION mifuncion() RETURNS void AS $$
BEGIN
FOR i IN 1..5 LOOP
copy (select nombre,dni,edad from test where id=i) TO 'C:\Users\Usuario\Documents\user'+i+'.csv' WITH CSV HEADER;
END LOOP;
END;
$$ LANGUAGE plpgsql;