我有一个带有 COPY TO A CSV FILE 的 Postgres 函数的问题,我有美元报价错误
这是功能
CREATE OR REPLACE FUNCTION save_audit_deletions(IN table_name text)
RETURNS void AS
$body$
DECLARE
interval INT;
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;
这是错误
Error executing: CREATE OR REPLACE FUNCTION save_audit_deletions(IN table_name text) RETURNS void AS
$body$
DECLARE
BEGIN
EXECUTE FORMAT ('COPY (SELECT * FROM %s WHERE backup = 1) TO ''/var/audiobays/logs/audit
. Cause: org.postgresql.util.PSQLException: Unterminated dollar quote started at position 87 in SQL CREATE OR REPLACE FUNCTION save_audit_deletions(IN table_name text)
RETURNS void AS
$body$
DECLARE
BEGIN
EXECUTE FORMAT ('COPY (SELECT * FROM %s WHERE backup = 1) TO ''/var/audiobays/logs/audit
. Expected terminating $$
Error executing: END
$body$
LANGUAGE plpgsql;
. Cause: org.postgresql.util.PSQLException: Unterminated dollar quote started at position 5 in SQL END
$body$
LANGUAGE plpgsql;
. Expected terminating $$"