I have a problem with my COPY on sqlWorkbench. I need to do a copy function from db TO a path that I create at the moment because is different for each table. I have this error ' ERROR: syntax error at or near "||"'
I have created the path with the concat operator but i have the error at ||
CREATE OR REPLACE FUNCTION copy_func(IN table_name text, IN days numeric)
RETURNS void AS
$body$
DECLARE
BEGIN
COPY (SELECT * FROM table_name WHERE backup = 1) TO '/var/audiobays/logs/audit/' || table_name || '_deletions_(' || date-days|| ').csv' CSV DELIMITER ',' HEADER;
END
$body$
LANGUAGE plpgsql;