X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1C5A2528B2 for ; Wed, 1 Jun 2005 12:37:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54526-10 for ; Wed, 1 Jun 2005 15:36:52 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id E358552834 for ; Wed, 1 Jun 2005 12:36:51 -0300 (ADT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id j51FLr9W017189; Wed, 1 Jun 2005 18:21:53 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id j51FLrde017185; Wed, 1 Jun 2005 18:21:53 +0300 Date: Wed, 1 Jun 2005 18:21:53 +0300 (EEST) From: Achilleus Mantzios To: David Klugmann Cc: pgsql-sql@postgresql.org Subject: Re: View unique rowid In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/7 X-Sequence-Number: 21608 O David Klugmann έγραψε στις Jun 1, 2005 : > > Hi > Is it possible to refer to a unique row identifier on a view ? > > I have the following view but in a subsequent select I need to refer to > each row's unique identifier and I know oid's are not valid for a view. Provided your ids are 4 bytes long, you could try to build an artificial id as > > create view persontransit > as > select personid, planet, name as aspectname, position as planetposition, SELECT personid::int8 as viewid,.... > position+angle as transitposition > from personplanet, aspect > union > select personid, planet, name as aspectname, position as planetposition, SELECT X'1'::int8<<32 | personid::int8 as viewid... > position-angle as transitposition > from personplanet, aspect > where name != 'OPPOSITION'; > > Many thanks > > David > that way the viewid is unique, + you know which part of the view it represents by masking on the 33th bit (4294967296), while you can get the actual personid by masking with X'FFFFFFFF' (4294967295) > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > -- -Achilleus