X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 581F8D1DB5C for ; Wed, 21 Apr 2004 17:22:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20643-05 for ; Wed, 21 Apr 2004 17:22:48 -0300 (ADT) Received: from web20809.mail.yahoo.com (web20809.mail.yahoo.com [216.136.226.198]) by svr1.postgresql.org (Postfix) with SMTP id D02F7D1DB23 for ; Wed, 21 Apr 2004 17:22:42 -0300 (ADT) Message-ID: <20040421202241.57574.qmail@web20809.mail.yahoo.com> Received: from [24.248.12.72] by web20809.mail.yahoo.com via HTTP; Wed, 21 Apr 2004 13:22:41 PDT Date: Wed, 21 Apr 2004 13:22:41 -0700 (PDT) From: Jeff Eckermann Subject: Re: Dealing with Insert Problems with Access To: Philippe Lang Cc: pgsql-odbc@postgresql.org In-Reply-To: <6C0CF58A187DA5479245E0830AF84F420802BA@poweredge.attiksystem.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/115 X-Sequence-Number: 4010 --- Philippe Lang wrote: > > Between the moment you have fetched the next id, and > the moment Access > does the insert into the table, another user or > process could so the > same thing, and fetch the exact same next id, which > would result in an > insert conflict, no? If I'm not wrong, in order to No. The "nextval" function returns the next available sequence number, and advances the sequence at the same time. So a subsequent call will never get the same number. > have something fully > multiuser-safe, you should use a stored procedure, > and even switch to a > serializable isolation level. I personally use LOCK > TABLE. Then, with With MVCC, it is almost never necessary to lock a table (I've never needed to). > the id your stored procedure gives you back, you > open the record from > Access. > > The problem, with that solution, is that it requires > a stored procedure > call prior to typing any data. It does not solve the > problem we may > encounter with a raw linked table or subform in > Access, when the data > being inserted is already present in another row of > the table. In that > case, as mentioned in posts last week, the id > fetched back may be wrong! > That's really dangerous... > > That's why I like your second solution: there must > be a way of forcing > Access to generate client-side a timestamp (with > miliseconds) or some > sort of unique random number, before each insert. In > that case, the id > fetched back by Access is 99.999999% the one you > expect. If I'm not > wrong, this kind of "trick" is even advised with an > SQL Server backend, > too... Yes, I am sure this solution would work fine. Which is why I had to think a bit before choosing. > > > Philippe Lang __________________________________ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com/ph/print_splash