On Tue, 14 May 2002, Erwin Ambrosch wrote:
> Hi,
>
> the following doesn't work.
>
> SELECT setval('int_article_id_seq', SELECT max(id) FROM int_article);
>
> I also tried to cast in the second argument, but with no success.
>
> SELECT setval('int_article_id_seq', SELECT CAST(max(id) FROM int_article AS
> INT4));
You're doing it (just a little bit) wrong. sub selects should ALWAYS be
enclosed by () pairs, so...
SELECT setval('int_article_id_seq', (SELECT CAST(max(id) FROM int_article
AS INT4)));
should work (it does on my system).