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 008B7D1D088 for ; Thu, 8 Apr 2004 14:11:49 -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 25990-03 for ; Thu, 8 Apr 2004 14:11:43 -0300 (ADT) Received: from mail.sells.com (mail.sells.com [204.107.136.10]) by svr1.postgresql.org (Postfix) with ESMTP id 7ADC0D1CCAC for ; Thu, 8 Apr 2004 14:11:41 -0300 (ADT) Received: from [192.168.5.55] (192.168.5.55) by mail.sells.com with ESMTP (Eudora Internet Mail Server 3.2.3) for ; Thu, 8 Apr 2004 12:11:40 -0500 Mime-Version: 1.0 X-Sender: aspeitia@mail.int.sells.com Message-Id: Date: Thu, 8 Apr 2004 12:11:36 -0500 To: pgsql-odbc@postgresql.org From: Ray Aspeitia Subject: Re: Access - ODBC - serial problem... Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/65 X-Sequence-Number: 3960 I haven't tried this in Access, but why not fetch the record identifier first then insert the record like below. Retrieving the id first makes sure that you get the right id, because you might be in a pooled connection environment, and you might not get the right id after the insert. SELECT nextval('schema.sequence_for_table_record_id') AS record_id; INSERT INTO test (record_id,code) VALUES ([retrieved record_id],20); or INSERT INTO test (record_id,code) VALUES (currval('schema.sequence_for_table_record_id'),20); Ray A. >Hello, > >I have made some more tests regarding my precedent post "[ODBC] >Access - ODBC - index strange bug", and in fact it is not >index-related. The bug is just more visible when an index is used, >apparently. > >The problem comes from the serial identifier, which is not know from >the client at the time the record is being inserted. > >With the table described below, imagine I do, from the client: > >insert into test (code) VALUES (20); > >How does the client know the id that has been given to the record? >With ethereal, I could see Access fetches the id by doing a > >select id from test where code = 20" > >Of course, another record has the same code, and the wrong id is >being fetched back. This explains what I have noticed, and that is >explained below... > >Is there a solution to that, except inserting records with PL-PGSQL, >which I already do in some cases, by the way...? > >Is that an Access-related problem? Does it work with SQL Server? > > >Thanks for your feedback... > >Philippe >