From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Tomi NA <hefest(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: ALTER SEQUENCE ... RESTART WITH [variable] problem |
Date: | 2006-05-20 07:55:42 |
Message-ID: | 20060520075542.GB30476@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, May 20, 2006 at 09:52:29AM +0200, Tomi NA wrote:
> I need to generate a couple of dozen statements reseting my sequences
> so that they're next values are greater than the biggest existing ids.
> The problem is, I can't even form a statement to update one sequence.
> This is what I tried:
<snip>
> The problem seems to be the ALTER statement:
>
> ERROR: syntax error at or near "$1" at character 36
> QUERY: ALTER SEQUENCE pk_table1 RESTART $1
> CONTEXT: SQL statement in PL/PgSQL function "init_sequences" near line 5
Seems you can't use a variable there. Your choices are to build a
string and use EXECUTE, or just do:
SELECT setval('sequence',value);
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
From | Date | Subject | |
---|---|---|---|
Next Message | Tomi NA | 2006-05-20 09:46:25 | Re: ALTER SEQUENCE ... RESTART WITH [variable] problem |
Previous Message | Tomi NA | 2006-05-20 07:52:29 | ALTER SEQUENCE ... RESTART WITH [variable] problem |