0

I have a stored procedure for copying details from csv file to database table.

CREATE FUNCTION gis_portal.copycsv(IN path text) RETURNS void AS $$
COPY gis_portal.temp_excel FROM path WITH DELIMITER ','
$$ LANGUAGE sql VOLATILE LEAKPROOF;

But it is showing error as:

ERROR: syntax error at or near "path" SQL state: 42601 Character: 101

Here path is dynamic. Please help me.

1 Answer 1

0

COPY statement doesn't support variables - only statements with plan does it. And SQL language doesn't support dynamic SQL - so you should to use plpgsql language

see Dynamically-generated table-name in PostgreSQL COPY command

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.