On May 9, 2006, at 10:59 , Hari Patel wrote:
> CREATE function set_sequence_ids() RETURNS INTEGER AS '
> DECLARE
> arg INTEGER;
> BEGIN
> select into arg max(id) from foo;
> select setval('foo_id_seq', 10);
> return arg;
> END;
> ' LANGUAGE 'plpgsql';
>
> I get the following error in psql.
>
> psql:func.sql:9: ERROR: syntax error at or near "foo_id_seq" at
> charact
> er 152
> psql:func.sql:9: LINE 6: select setval('foo_id_seq', 10);
> psql:func.sql:9: ^
Try just
setval('foo_id_seq',10)
or
PEFORM setval('foo_id_seq', 10)
It's just a function call, and since you're not saving the return
value, you don't use SELECT. SELECT has different syntax in PL/pgSQL
than in SQL.
Hope this helps.
Michael Glaesemann
grzm seespotcode net