Re: Replacement for Oracle's "ROWNUM" in Postgres

From: Bill Gribble <grib(at)linuxdevel(dot)com>
To: Csaba Nagy <nagy(at)domeus(dot)de>
Cc: 'pgsql-general' <pgsql-general(at)postgresql(dot)org>
Subject: Re: Replacement for Oracle's "ROWNUM" in Postgres
Date: 2002-12-19 17:30:01
Message-ID: 1040319001.5896.40.camel@firetrap.internal.billgribble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2002-12-19 at 10:58, Csaba Nagy wrote:
> This query is setting a date into a column for all the rows, starting with a
> fixed date with 10 minutes intervals.
>
> UPDATE some_table
> SET some_date_column = 'some_literal_date' + (ROWNUM / 144.0);
>
> It is used to initialize a table with data.
> Is there any way to get the same result in Postgres somehow ?

One way:

CREATE SEQUENCE dateseq;

UPDATE some_table
SET some_date_column = 'some_literal_date' +
(nextval('dateseq') / 144.0)

DROP SEQUENCE dateseq;

b.g.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lee Kindness 2002-12-19 17:35:47 Re: Table Timemachine!
Previous Message Larry Rosenman 2002-12-19 17:29:03 Re: trouble caused by change in 7.3 handling of '' in