Re: execute transaction / insert rows

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: 'Andrew Sullivan' <andrew(at)libertyrms(dot)info>, pgsql-general(at)postgresql(dot)org
Subject: Re: execute transaction / insert rows
Date: 2002-10-01 18:46:54
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB04C73FF7@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--thanks for the reply:

--i'm sorry i was not clear with my goals, but
--that is exactly what i'm trying to do - however,
--i was trying to figure out if there was a way to
--do this with SQL.

--like

[pseudo code]

begin
update table
set col = new
from old_table
where new = better
set transaction = 1000 records (* no clue on this part! *)
commit 1000;
end

[/code]

--any suggestions?

-X

-----Original Message-----
From: Andrew Sullivan [mailto:andrew(at)libertyrms(dot)info]

On Tue, Oct 01, 2002 at 01:48:38PM -0400, Johnson, Shaunn wrote:
> Howdy:
>
> Running PostgreSQL 7.2.1 on RedHat Linux 7.2 kernel 2.4.7-10.
>
> Are there any examples out there to insert / update
> a table for every, say, 1000 records via SQL? I'm having
> a hard time just inserting into the table ... it seems
> that there isn't anything going on AND I need to commit
> the transaction if the query gets killed somehow.

I'm not sure I understand your question, but if I'm right, I've done
this with Perl. Just loop through a counter to 1000, commit, do
another 1000, &c. You can add a second counter for the remainder
(i.e. not divisible by 1000) bit, so you can add just that many the
last time. You can also check the error status after each 1000, and
abort if you run into problems.

A

--
----
Andrew Sullivan 204-4141 Yonge Street
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)info> M2P 2A8
+1 416 646 3304 x110

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Eckermann 2002-10-01 19:02:45 Re: Is it possible to import .txt files in PostgreySQL
Previous Message Ian Harding 2002-10-01 18:39:17 Core Dump