Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 67AA29FB251 for ; Wed, 11 Oct 2006 11:53:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 33840-09 for ; Wed, 11 Oct 2006 11:53:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from securetrans.mitrust.com (securetrans.mitrust.com [207.250.112.34]) by postgresql.org (Postfix) with ESMTP id 3757C9FA5DC for ; Wed, 11 Oct 2006 11:53:29 -0300 (ADT) Received: from [10.201.170.131] (tr2925.mi.micorp.com [10.201.170.131]) by securetrans.mitrust.com (Postfix) with ESMTP id A55FB4F407E; Wed, 11 Oct 2006 09:53:26 -0500 (CDT) Message-ID: <452D0566.9070600@amsoftwaredesign.com> Date: Wed, 11 Oct 2006 09:53:26 -0500 From: Tony Caduto User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Arnaud Lesauvage CC: pgsql-odbc@postgresql.org Subject: Re: Access2000 & sequence as primary key in view : #DELETED References: <452CAEC2.5070903@freesurf.fr> In-Reply-To: <452CAEC2.5070903@freesurf.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.06 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200610/23 X-Sequence-Number: 8286 Arnaud Lesauvage wrote: > Hi list ! > > I created a view in postgresql (quite complex, multiple tables are > linked). The aim is to link it in acces via ODBC. > > In needed to auto-number the rows, and I created a sequence for that > (thanks to a good advice on the GENERAL list). > > In Access, I know that I need good primary keys on my linked tables > (integer, single column). I though that using this column as a primary > key would be a good idea . > > The view looks like this : > CREATE OR REPLACE VIEW my_view AS > SELECT nextval('my_view_seq'::regclass)::integer AS "index", other fields> FROM ; > > Note I had to explicitely cast the sequence as integer, because it was > detected as a decimal field in Access (equivalent to NUMERIC in > PostgreSQL). > > In Access I link my tables via some VBA code. I have a routine that > creates the primary keys when they are non-trivial. In this case, the > routine executes "CREATE UNIQUE INDEX my_pkey ON TABLE my_linked_table > (index)". > > A unique index is not a primary key, you need to create the PK like this: ALTER TABLE products ADD CONSTRAINT some_name PRIMARY KEY (product_no); --Make sure you only use one column for the PK!! What we have found is that Access displays the #deleted when the Primary key is on more than one field and is not a integer value. Our solution was to use a Primary key field as a recid using a sequence (SERIAL type) and then to use a unique index on each column that would have normally been in the Primary Key. Once we did this the #deleted stuff went away. -- Tony Caduto AM Software Design http://www.amsoftwaredesign.com Home of PG Lightning Admin for Postgresql Your best bet for Postgresql Administration