Is there a way, using PL/pgSQL, to copy data from csv file to PostgreSQL table only if the file exists, something similar to this:
BEGIN
IF file_exists(filename) THEN
COPY table FROM 'filename' DELIMITER ',' CSV HEADER;
END IF;
END;
Is there a way, using PL/pgSQL, to copy data from csv file to PostgreSQL table only if the file exists, something similar to this:
BEGIN
IF file_exists(filename) THEN
COPY table FROM 'filename' DELIMITER ',' CSV HEADER;
END IF;
END;
you can try something like this:
select exists(select * from pg_ls_dir('directory_name') as file where file = 'fileName');
but the directory should exists. check this also