On Fri, Apr 27, 2012 at 11:35 AM, J.V. <jvsrvcs@gmail.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