Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 66E7A9FB1F6 for ; Wed, 7 Mar 2007 12:25:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 18631-01 for ; Wed, 7 Mar 2007 12:24:46 -0400 (AST) X-Greylist: delayed 00:12:15.567137 by SQLgrey-1.7.4 Received: from ex14.myhostedexchange.com (ex14.myhostedexchange.com [69.50.2.20]) by postgresql.org (Postfix) with ESMTP id 96EB89FA160 for ; Wed, 7 Mar 2007 12:24:45 -0400 (AST) X-MimeOLE: Produced By Microsoft Exchange V6.5 Received: from 205.238.79.158 ([205.238.79.158]) by ex14.hostedexchange.local ([69.50.2.20]) with Microsoft Exchange Server HTTP-DAV ; Wed, 7 Mar 2007 16:12:27 +0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C760D3.6671AA75" User-Agent: Microsoft-Entourage/11.2.5.060620 Content-class: urn:content-classes:message Subject: Re: Transaction atomicity Date: Wed, 7 Mar 2007 08:12:24 -0800 Message-ID: In-Reply-To: <1173283563.20645.53.camel@scarafaggio> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [JDBC] Transaction atomicity Thread-Index: Acdg02RForMOnszGEdu8EAANk0UQgg== From: "Jeff Hubbach" To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.502 tagged_above=0 required=5 tests=BAYES_50, HTML_MESSAGE, RCVD_NUMERIC_HELO X-Spam-Level: * X-Archive-Number: 200703/76 X-Sequence-Number: 16790 This is a multi-part message in MIME format. ------_=_NextPart_001_01C760D3.6671AA75 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable On 3/7/07 9:06 AM, "Giuseppe Sacco" wrote: > You are right, but I need different sequences for every user, i.e., if > two users insert on the same table then I need a way to use different > sequence. The reason of this is that I have to split my application = into > a few different postgresql instances based in different offices. Every > night all instances synchronise their data (this is and INSERT only > table), so I need a different table sequence in every office (or group > of users or single user). Using select(max(id)) won't work in this case, either (if I'm = understanding your setup correctly). So each office has its own postgresql instance. Then every night you = copy the data from all offices to all other offices. Therefore, that whole = day, inserts were made in each office instance with the same IDs, which will cause duplicate key exceptions. Why not have a compound key on this table, with an ID generated by a sequence (one sequence, named the same, for each instance of PostgreSQL = for each office), and an Office ID that is static for each instance? Then = the merge/sync would go through without a hitch.=20 ------_=_NextPart_001_01C760D3.6671AA75 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Re: [JDBC] Transaction atomicity

On 3/7/07 9:06 AM, "Giuseppe Sacco" = <giuseppe@eppesuigoccas.homedns.org>
wrote:

> You are right, but I need different sequences for every user, i.e., = if
> two users insert on the same table then I need a way to use = different
> sequence. The reason of this is that I have to split my application = into
> a few different postgresql instances based in different offices. = Every
> night all instances synchronise their data (this is and INSERT = only
> table), so I need a different table sequence in every office (or = group
> of users or single user).

Using select(max(id)) won't work in this case, either (if I'm = understanding
your setup correctly).

So each office has its own postgresql instance. Then every night you = copy
the data from all offices to all other offices. Therefore, that whole = day,
inserts were made in each office instance with the same IDs, which = will
cause duplicate key exceptions.

Why not have a compound key on this table, with an ID generated by a
sequence (one sequence, named the same, for each instance of PostgreSQL = for
each office), and an Office ID that is static for each instance? Then = the
merge/sync would go through without a hitch.

------_=_NextPart_001_01C760D3.6671AA75--