pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: Help with COPY command
4+ messages / 3 participants
[nested] [flat]
* Re: Help with COPY command
@ 1970-01-01 00:00 Christoph Haller <ch@rodos.fzk.de>
parent: Tony Reina <reina_ga@hotmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Haller @ 1970-01-01 00:00 UTC (permalink / raw)
To: reina_ga@hotmail.com; +Cc: pgsql-sql
>
> Ok. I found the libpq syntax for COPY in the Programmer's manual. I've
> got a working version, but wanted to verify something.
>
> PQexec(conn, "COPY foo FROM STDIN");
> PQputline(conn, "3\thello world\t4.5\n");
> PQputline(conn,"4\tgoodbye world\t7.11\n");
> ...
> PQputline(conn,"\\.\n");
> PQendcopy(conn);
>
> 1. I'm assuming that I can put in as many PQputline statements as I
> want to between the PQexec("COPY ... FROM ...") and the terminator
> line. Is that correct? No limit?
>
> 2. Do any of these lines need to be followed by a PQclear(res)? What
> about the first PQexec?
>
> -Tony
>
ad 1. Yes, no limit.
ad 2. I use PQclear following the PQexec.
Regards, Christoph
^ permalink raw reply [nested|flat] 4+ messages in thread
* Help with COPY command
@ 2004-04-06 20:31 Tony Reina <reina_ga@hotmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: reina_ga@hotmail.com @ 2004-04-06 20:31 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Help with COPY command
@ 2004-04-07 19:32 Tony Reina <reina_ga@hotmail.com>
parent: Tony Reina <reina_ga@hotmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: reina_ga@hotmail.com @ 2004-04-07 19:32 UTC (permalink / raw)
To: pgsql-sql
Ok. I found the libpq syntax for COPY in the Programmer's manual. I've
got a working version, but wanted to verify something.
PQexec(conn, "COPY foo FROM STDIN");
PQputline(conn, "3\thello world\t4.5\n");
PQputline(conn,"4\tgoodbye world\t7.11\n");
...
PQputline(conn,"\\.\n");
PQendcopy(conn);
1. I'm assuming that I can put in as many PQputline statements as I
want to between the PQexec("COPY ... FROM ...") and the terminator
line. Is that correct? No limit?
2. Do any of these lines need to be followed by a PQclear(res)? What
about the first PQexec?
-Tony
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Help with COPY command
@ 2004-04-14 15:54 Tony and Bryn Reina <reina_ga@hotmail.com>
parent: Christoph Haller <ch@rodos.fzk.de>
0 siblings, 0 replies; 4+ messages in thread
From: Tony and Bryn Reina @ 2004-04-14 15:54 UTC (permalink / raw)
To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-sql
Thanks for the reply.
-Tony
----- Original Message -----
From: "Christoph Haller" <ch@rodos.fzk.de>
To: "Tony Reina" <reina_ga@hotmail.com>
Cc: <pgsql-sql@postgresql.org>
Sent: Wednesday, April 14, 2004 5:42 PM
Subject: Re: [SQL] Help with COPY command
> >
> > Ok. I found the libpq syntax for COPY in the Programmer's manual. I've
> > got a working version, but wanted to verify something.
> >
> > PQexec(conn, "COPY foo FROM STDIN");
> > PQputline(conn, "3\thello world\t4.5\n");
> > PQputline(conn,"4\tgoodbye world\t7.11\n");
> > ...
> > PQputline(conn,"\\.\n");
> > PQendcopy(conn);
> >
> > 1. I'm assuming that I can put in as many PQputline statements as I
> > want to between the PQexec("COPY ... FROM ...") and the terminator
> > line. Is that correct? No limit?
> >
> > 2. Do any of these lines need to be followed by a PQclear(res)? What
> > about the first PQexec?
> >
> > -Tony
> >
> ad 1. Yes, no limit.
> ad 2. I use PQclear following the PQexec.
>
> Regards, Christoph
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-04-14 15:54 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-06 20:31 Help with COPY command Tony Reina <reina_ga@hotmail.com>
2004-04-07 19:32 ` Tony Reina <reina_ga@hotmail.com>
1970-01-01 00:00 ` Christoph Haller <ch@rodos.fzk.de>
2004-04-14 15:54 ` Tony and Bryn Reina <reina_ga@hotmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox