pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: David Klugmann <dklugmann@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: View unique rowid
Date: Wed, 1 Jun 2005 18:21:53 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0506011805190.16893-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <BAY104-F738FF8AD0C05D867CF6D5B2050@phx.gbl>

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




view thread (4+ messages)

Message-ID: <Pine.LNX.4.44.0506011805190.16893-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0506011805190.16893-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0506011805190.16893-100000@matrix.gatewaynet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: achill@matrix.gatewaynet.com, dklugmann@hotmail.com
  Subject: Re: View unique rowid
  In-Reply-To: <Pine.LNX.4.44.0506011805190.16893-100000@matrix.gatewaynet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox