pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rodrigo De León <rdeleonp@gmail.com>
To: pgsql-sql@postgresql.org, "Trigve Siver" <trigves@yahoo.com>
Subject: Re: slow query execution
Date: Wed, 30 May 2007 12:28:47 -0500
Message-ID: <a55915760705301028r69887f67q2efcb814550b80c5@mail.gmail.com> (raw)
In-Reply-To: <710412.41081.qm@web52709.mail.re2.yahoo.com>
References: <710412.41081.qm@web52709.mail.re2.yahoo.com>

On 5/30/07, Trigve Siver <trigves@yahoo.com> wrote:
> Can you point me to some sources
> or give me some examples, please?

CREATE OR REPLACE FUNCTION ROWNUM() RETURNS BIGINT AS
$$
	BEGIN
		RETURN NEXTVAL('ROWNUM_SEQ');
	EXCEPTION WHEN OTHERS THEN
		CREATE TEMP SEQUENCE ROWNUM_SEQ;
		RETURN NEXTVAL('ROWNUM_SEQ');
	END;
$$
LANGUAGE 'PLPGSQL';

SELECT ROWNUM(), S.X
FROM GENERATE_SERIES(5,1,-1) S(X);

Remember to reset the sequence value if you use this more than once in
the same session.



view thread (16+ messages)  latest in thread

Message-ID: <a55915760705301028r69887f67q2efcb814550b80c5@mail.gmail.com>
Permalink:  ../a55915760705301028r69887f67q2efcb814550b80c5@mail.gmail.com/
Also on:    postgresql.org/message-id/a55915760705301028r69887f67q2efcb814550b80c5@mail.gmail.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: rdeleonp@gmail.com, trigves@yahoo.com
  Subject: Re: slow query execution
  In-Reply-To: <a55915760705301028r69887f67q2efcb814550b80c5@mail.gmail.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