I'm trying to copy data into a table from a stored PostgreSQL function. The data of rows and the table name are received from a java program and the part that causes errors is this one:
_copyquery := FORMAT('COPY %s FROM STDIN (DELIMITER ''|'', FORMAT CSV); %s \.', _tablename, _stdin);
execute _copyquery;
Where the _tablename is the name of the table and the _stdin are the rows of data formatted as such:
12|34|139901177705664|1545226308991|991389|1545226308991|1545226308991|0|0|0|0|0|0|000|0.0.0.0|0.0.0.0|2328620776|0|0|0|0|0|0|0|0.0.0.0|0.0.0.0|0|0|0|0||0|0|0|-|0|0|0|0|0|195.46.227.124|33840|10.110.186.41|2123|2|0|3090304976|0.0.0.0|::|0|||0|0|0|0|0|0|0|0|2|5
The error I get is :
ERROR: syntax error at or near "12"
where the "12" is always the first field, most commonly 12 or 3. Any ideas why this isn't working out?
I've found out that my request is currently impossible to do and have settled on using the CopyManager to insert data programmatically. Keep in mind with the volumes of data I was working with insert statements would be way to slow and this is a good solution.