Multiple inserts without COPY - Mailing list pgsql-admin

From Mark Lubratt
Subject Multiple inserts without COPY
Date
Msg-id B1385542-6D86-11D8-BC23-000A9579AF50@indeq.com
Whole thread Raw
Responses Re: Multiple inserts without COPY  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
Hello!

I have a routine in my application where I have the potential to
generate hundreds of inserts or deletes at one time.  Right now, I
issue each insert and delete separately.  I'm hoping there might be a
way of generating a single SQL statement to send to the backend for
each.  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.

The inserts might look like

insert into CL (CO_id, PE_ID) values (j, k)

where j and k are also integers and I could have a list of several
hundred pairs of j and k.

MySQL has a multiple insert feature where you simply append a bunch of
(j, k)'s separated by a comma.  Does PostgreSQL have anything like
this?  I was hoping I might be able to use COPY, but I see that's
really only for psql.

Are there any options?  Or, do I simply send a bunch of queries?

Thanks!
Mark


pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: bizarre AGE behaviour
Next
From: Tom Lane
Date:
Subject: Re: Multiple inserts without COPY