Help with COPY command

From: reina_ga(at)hotmail(dot)com (Tony Reina)
To: pgsql-sql(at)postgresql(dot)org
Subject: Help with COPY command
Date: 2004-04-06 20:31:43
Message-ID: 272e4be7.0404061231.5dffc541@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm attempting to use the COPY command through the libpq C functions.
In the psql command line editor, I'd have the following commands:

COPY testtable FROM stdin WITH DELIMITER ',';
1, 2, 'a', 3, 4
5, 6, 'b', 7, 8
9, 10, 'c', 11, 12
\.

My question is:

Does this all have to be passed as one big command through libpq? For
example,

res = PQexec(conn, "COPY testtable FROM stdin WITH DELIMITER ',';\n",
"1, 2, 'a', 3, 4\n5, 6, 'b', 7, 8\n9, 10, 'c', 11, 12\n\.");

Or, can it be broken up into separate lines? For example,

res = PQexec(conn, "COPY testtable FROM stdin WITH DELIMITER ',';");
res = PQexec(conn, "1, 2, 'a', 3, 4");
res = PQexec(conn, "5, 6, 'b', 7, 8");
res = PQexec(conn, "9, 10, 'c', 11, 12");
res = PQexec(conn, "\.");

-Tony

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2004-04-07 04:29:54 Re: Getting the ranks of results from a query
Previous Message Richard Huxton 2004-04-06 19:54:07 Re: partial unique constraint