Re: temp sequence

From: Andy Colson <andy(at)squeakycode(dot)net>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: temp sequence
Date: 2010-05-05 14:01:57
Message-ID: 4BE17A55.4000508@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/5/2010 2:36 AM, Sim Zacks wrote:
> I am using 8.2.14
>
> I am trying to use a temp sequence in a function and I'm having a lot of
> trouble.
> I create the temp sequence and then I have to drop it at the end of the
> function, because it stays alive for the whole session and not just the
> function.
> I want to use the nextval function in an update statement so it gives a
> sequence number to each row it updates.
> If I drop the sequence and recreate it I get an OID not found error.
> I tried to run the update statement dynamically, but part of the update
> stmt is an int array variable and it won't cast it to text.
>
> My goal in the end is that every row that is updated will be numbered
> sequentially per update.
>
> Do you have any ideas?
>
> Sim
>

Perhaps you can rewrite to use generate_series instead?

http://www.postgresql.org/docs/8.0/interactive/functions-srf.html

-Andy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message pasman pasmański 2010-05-05 14:11:50 Multilevel partitioning
Previous Message Andy Colson 2010-05-05 13:57:00 Re: database Benchmark, TPC, PostgreSQL and TPC-E