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: signature.asc
Description: Digital signature

Reply via email to