From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | "J(dot)V(dot)" <jvsrvcs(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: how to create a sequence in a stored proc? |
Date: | 2012-04-27 16:57:08 |
Message-ID: | CAHyXU0zUaKPEd=uKFvtJAaoGkfP4whzZqcMP4xNB+QtsAsf1ZQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Apr 27, 2012 at 11:35 AM, J.V. <jvsrvcs(at)gmail(dot)com> wrote:
> Right, I understand that fully, and have used SQL inside a stored proc
> before, but in this case as I mentioned, I need to first do a select from a
> table to get a max value, store that in a variable and then use that
> variable in a create sequence sql statement.
>
> so I need to construct a string that contains the create sequence statement
> and execute that string, at least this is the way it is done in Oracle.
>
> I do not know how to use a variable in a create sequence statement in
> PostgreSQL.
oh I see. try this:
postgres=# do
$$
declare
s int default 3;
begin
execute 'create sequence v start ' || s;
end;
$$ language plpgsql;
DO
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Raymond O'Donnell | 2012-04-27 17:05:57 | Re: how to create a sequence in a stored proc? |
Previous Message | Filip Rembiałkowski | 2012-04-27 16:35:58 | Re: empty role names in pg_dumpall output |