Re: execute transaction / insert rows - Mailing list pgsql-general

From Johnson, Shaunn
Subject Re: execute transaction / insert rows
Date
Msg-id 73309C2FDD95D11192E60008C7B1D5BB04C73FF7@snt452.corp.bcbsm.com
Whole thread Raw
In response to execute transaction / insert rows  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
Responses Re: execute transaction / insert rows  (Andrew Sullivan <andrew@libertyrms.info>)
List 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@libertyrms.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@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110

pgsql-general by date:

Previous
From: "Ian Harding"
Date:
Subject: Core Dump
Next
From: Jeff Eckermann
Date:
Subject: Re: Is it possible to import .txt files in PostgreySQL