Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 374309FB203 for ; Thu, 23 Nov 2006 10:30:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 58568-01 for ; Thu, 23 Nov 2006 10:30:25 -0400 (AST) X-Greylist: delayed 00:32:43.620299 by SQLgrey-1.7.4 Received: from mail.toxisch.net (mail.toxisch.net [88.198.180.59]) by postgresql.org (Postfix) with ESMTP id 364FE9FB1E7 for ; Thu, 23 Nov 2006 10:30:22 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.toxisch.net (Postfix) with ESMTP id 4313B77A8C for ; Thu, 23 Nov 2006 14:58:14 +0100 (CET) Received: from mail.toxisch.net ([127.0.0.1]) by localhost (toxisch.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 28732-07 for ; Thu, 23 Nov 2006 14:58:05 +0100 (CET) Received: from mavis (www-cache.bocholt.fh-gelsenkirchen.de [193.175.197.50]) by mail.toxisch.net (Postfix) with ESMTP id 286DA77A78 for ; Thu, 23 Nov 2006 14:58:05 +0100 (CET) Date: Thu, 23 Nov 2006 14:57:27 +0100 From: Niels Laakmann To: pgsql-interfaces@postgresql.org Subject: Re: ECPG and COPY FROM STDIN In-Reply-To: <200611200642.23872.sdavis2@mail.nih.gov> References: <20061120111317.9889D77A3B@mail.toxisch.net> <200611200642.23872.sdavis2@mail.nih.gov> X-Mailer: Sylpheed-Claws 2.4.0 (GTK+ 2.8.18; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20061123135805.286DA77A78@mail.toxisch.net> X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.toxisch.net X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/10 X-Sequence-Number: 6325 Am heiligen Mo, 20 November 2006 06:42:23 -0500 schrieb Sean Davis : > On Monday 20 November 2006 06:12, Niels Laakmann wrote: > > Hey List! > > I have to do a Benchmark-Test in C (ECPG) with and without network. > > After reading the Performance and COPY Documentation (not correctly), I > > wanted to Copy a File over the Network by using "COPY FROM 'filename'". > > After some curious Problems I knew why. > > Now I read some about "COPY FROM STDIN. But I didn't find an Example. > > Can someone please give me an Example for that ? > > > > Or: > > > > Is there another command to insert many tuples from a Client to a > > Server in an adequate time ? > > How about here: > > http://www.postgresql.org/docs/8.1/interactive/libpq-copy.html At first thanks for this Tipp. I rewrite my Code to use Libpq now. But the next Problem comes up: char textbuffer[120]; result = PQexec(connect, "COPY branches (branchid, branchname, balance, address) FROM STDIN WITH DELIMITER ',';"); if(PQresultStatus(result) != PGRES_COPY_IN) shutdown_conn(1, connect); //my own error-handling //function for(n=0; n < count_tupel; n++) { sprintf(textbuffer, "%d,text1,0,text2", n); if(PQputCopyData(connect, textbuffer, strlen(textbuffer) + 1) != 1) shutdown_conn(1, connect); } PQputCopyEnd(connect, NULL); PQgetResult(connect); If count_tupel is 1, one Tupel is inserted to the relation. If count_tupel is greater than 1. No Tupel is inserted and I got the Error-Message: "extra data after last expected column". What are we doing wrong ? - Is there something wrong as I discard the buffer ? - A Null-Termination etc. ? The other thing is, that I've looked for some libpq-copy - examples. But neither in the postgresql-src nor on some postgres-related internet-pages, I found one. Can anyone help ? - Thanks - Niels > > Sean >