Re: Question about setval() function

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: <ambre(at)ebutec(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question about setval() function
Date: 2002-05-14 16:16:05
Message-ID: JGEPJNMCKODMDHGOBKDNCEDKCOAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Erwin Ambrosch
> Sent: Tuesday, May 14, 2002 10:19 AM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] Question about setval() function
>
> the following doesn't work.
>
> SELECT setval('int_article_id_seq', SELECT max(id) FROM int_article);

Nope. A select statement isn't itself a valid argument to a function. Turn
it into a subselect with parens:

SELECT setval('seq_name', ( SELECT max(id) FROM a_table ) );

- J.

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joel Burton 2002-05-14 16:17:24 Re: Question about SERIAL
Previous Message Stephan Szabo 2002-05-14 15:50:39 Re: restoring databases with intensive foreign key use