Re: how to create a sequence in a stored proc?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: "J(dot)V(dot)" <jvsrvcs(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: how to create a sequence in a stored proc?
Date: 2012-04-27 15:51:55
Message-ID: CAHyXU0x=kmb6AE0C68EEFG4ReGjww9AjwALdfBiR_NV4VnwHjg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Apr 27, 2012 at 10:37 AM, J.V. <jvsrvcs(at)gmail(dot)com> wrote:
> I need to create a sequence in a stored procedure.
>
> First I need to select a value from a table and set the sequence start value
> to that value.
>
> We have a table that does not have a sequence on it, so I want to select the
> max value, increment by one
> and then start the sequence there.
>
> We have to do this on three databases, I have figured out how to do this in
> Oracle (build a string and the EXECUTE IMMEDIATE <myString>, but have not
> figured out how to do this with PostgreSQL.

just about any sql is allowed from within a function, including CREATE
SEQUENCE. functions can even create functions and execute them.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message J.V. 2012-04-27 16:35:01 Re: how to create a sequence in a stored proc?
Previous Message J.V. 2012-04-27 15:37:11 how to create a sequence in a stored proc?