Mark Lubratt
2004-03-04 02:50:27 UTC
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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html