Note that there are some explanatory texts on larger screens.

plurals
  1. POCOPY command in Postgresql Inquiry
    text
    copied!<p>Good day!</p> <p>I would like to inquire about COPY command in Postgresql. I have this table:</p> <pre><code>CREATE TABLE pm_monitor_temporary ( date timestamp NOT NULL, targetid varchar(128) NOT NULL, value1 float8 NOT NULL, value2 float8 NOT NULL, value3 float8 NOT NULL, value4 float8 NOT NULL, value5 float8 NOT NULL, value6 float8 NOT NULL, datastatus1 varchar(2) NOT NULL, datastatus2 varchar(2) NOT NULL, datastatus3 varchar(2) NOT NULL, datastatus4 varchar(2) NOT NULL, datastatus5 varchar(2) NOT NULL, datastatus6 varchar(2) NOT NULL, granularity int4 NOT NULL, neid varchar(16) NOT NULL, CONSTRAINT pm_monitor_pkey PRIMARY KEY (date, targetid, granularity, neid) ); </code></pre> <p>I did create a function that will copy csv contents into the table given the filePath(absolute path of the file). There seems to be a problem with my sql function.:</p> <pre><code>Create Or Replace Function copycsv_pm_monitor_temp(filePath varchar(1025)) Returns void As $BODY$ DECLARE sql varchar(1025); BEGIN sql := 'COPY pm_monitor_temporary FROM {' || filePath || '| stdin} using DELIMITERS ',' ' || ';' ; EXECUTE sql; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE; </code></pre> <p>This will compile, however this will eventually result to error when i run my java code. Did i miss something? </p> <pre><code>Caused by: org.postgresql.util.PSQLException: ERROR: query "SELECT 'COPY pm_monitor_temporary FROM {' || $1 || '| stdin} using DELIMITERS ',' ' || ';'" returned 2 columns </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload