X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AD461D1B4B0 for ; Thu, 4 Mar 2004 05:12:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 22577-06 for ; Thu, 4 Mar 2004 01:12:50 -0400 (AST) Received: from secure.icanx.com (secure.icanx.com [64.246.58.55]) by svr1.postgresql.org (Postfix) with ESMTP id 18467D1B470 for ; Thu, 4 Mar 2004 01:12:51 -0400 (AST) Received: from 63-229-201-197.mpls.qwest.net ([63.229.201.197] helo=[192.168.2.102]) by secure.icanx.com with esmtp (Exim 4.24) id 1AylA9-0004Bk-6r; Thu, 04 Mar 2004 00:12:49 -0500 In-Reply-To: <21228.1078374155@sss.pgh.pa.us> References: <21228.1078374155@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <9319A042-6D9A-11D8-B976-000A9579AF50@indeq.com> Content-Transfer-Encoding: 7bit Cc: pgsql-admin@postgresql.org From: Mark Lubratt Subject: Re: Multiple inserts without COPY Date: Wed, 3 Mar 2004 23:12:46 -0600 To: Tom Lane X-Mailer: Apple Mail (2.612) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - secure.icanx.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - indeq.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/20 X-Sequence-Number: 12590 On Mar 3, 2004, at 10:22 PM, Tom Lane wrote: > Mark Lubratt writes: >> The deletes look something like >> delete from CL where CL_id = i >> where i could be a list of several hundred integers. Again, right now >> I iterate through the list. > > Consider > delete from CL where CL_id in (i,j,k,...); > If you have hundreds of target values, it might be better to put them > in > a temp table and go > delete from CL where CL_id in (select id from temp_table); > The latter should be reasonably quick in 7.4, but be warned that it'll > suck in prior releases. > Yeah, that's what I was looking for! I thought I might be able to do that. Cool. >> I was hoping I might be able to use COPY, but I see that's >> really only for psql. > > Huh? You can use COPY FROM STDIN in most of our client libraries, > certainly so with libpq. What are you using? > Actually, I'm using REALbasic. All the communication is happening through a TCP connection. I tried emulating what the command might look like in pgAdmin. But, of course, after the semi-colon, the parser got confused when it hit the actual data. I tried: COPY MyTable (id, val) FROM STDIN; 2 Hello There! \. It choked at the 2. I was just trying to see if the backend suspended parsing and would just start copying like psql does. But, I guess not. How does psql shovel a COPY at the backend? Oooh. I just remembered. There is a new method in the REALbasic classes that provide the PostgreSQL functionality. I'll have to check it out... I was hoping that there might be a syntax trick with INs or something like the delete command above. Something that might expand in the parser to do what I want to do. Thanks! Mark