Re: Can I getting a unique ID from a select

From: Bill Moran <wmoran(at)collaborativefusion(dot)com>
To: "Timasmith" <timasmith(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can I getting a unique ID from a select
Date: 2007-03-01 16:24:53
Message-ID: 20070301112453.173b4770.wmoran@collaborativefusion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In response to "Timasmith" <timasmith(at)hotmail(dot)com>:

> I am using hibernate, using a view like a read only table and I need a
> primary key each time a select is issued.
>
> So in Oracle terms this might work, though I am skeptical that
> Hibernate is going to return a cached result.
>
> create view myview as
> select rownum, t1.field, t2.field
> from tableOne t1, tableTwo t2
> where t1.key = t2.fkey
>
> select * from myview
>
> But what I really need is
>
> select makemeauniquekey, t1.field, t2.field
> ...
>
> Maybe there is no way I think... incrementing a sequence per select
> is untenable.

Create a sequence and use nextval().

--
Bill Moran
Collaborative Fusion Inc.

wmoran(at)collaborativefusion(dot)com
Phone: 412-422-3463x4023

****************************************************************
IMPORTANT: This message contains confidential information and is
intended only for the individual named. If the reader of this
message is not an intended recipient (or the individual
responsible for the delivery of this message to an intended
recipient), please be advised that any re-use, dissemination,
distribution or copying of this message is prohibited. Please
notify the sender immediately by e-mail if you have received
this e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The
sender therefore does not accept liability for any errors or
omissions in the contents of this message, which arise as a
result of e-mail transmission.
****************************************************************

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2007-03-01 16:26:34 Re: supporting 2000 simultaneous connections.
Previous Message Bill Moran 2007-03-01 16:22:16 Re: supporting 2000 simultaneous connections.