PDA

View Full Version : QPSQL unable to COPY large files



dehm
23rd January 2021, 17:48
I am trying to make a fuction for create a large table from file using COPY (https://www.postgresql.org/docs/9.2/sql-copy.html).
My function create the *.csv file properly.
After, my function generate the query, who calls to a postgres function that uses COPY command.

This is the postgres function:


CREATE OR REPLACE FUNCTION importar_copy(
_nombretabla character varying,
_ruta character varying)
RETURNS boolean AS
$BODY$
DECLARE
texto text;
BEGIN
texto = FORMAT ('COPY %I FROM %s DELIMITER %s NULL AS ''NULL''', _nombretabla, quote_literal(_ruta), quote_literal(chr(9)));
execute (texto);
raise notice '%',texto;
return true;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;

As well as I have said, the function in Qt generate the query properly. And the file is also properly generate. If I copy the query generate in Qt and paste in pgAdmin, the query works, but if I try to exec from my Qt application, is like if it can manage a large file and stop to read in any place of it.

Maybe someone knows what could happens?
Thank you very much!