Re: ALTER SEQUENCE ... RESTART WITH [variable] problem - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: ALTER SEQUENCE ... RESTART WITH [variable] problem
Date
Msg-id 20060520075542.GB30476@svana.org
Whole thread Raw
In response to ALTER SEQUENCE ... RESTART WITH [variable] problem  ("Tomi NA" <hefest@gmail.com>)
Responses Re: ALTER SEQUENCE ... RESTART WITH [variable] problem  ("Tomi NA" <hefest@gmail.com>)
List 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@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: "Tomi NA"
Date:
Subject: ALTER SEQUENCE ... RESTART WITH [variable] problem
Next
From: "Tomi NA"
Date:
Subject: Re: ALTER SEQUENCE ... RESTART WITH [variable] problem