Michelle Konzack wrote:
-- Start of PGP signed section.
> Hello Michael,
> 
> Am 2008-10-31 11:15:54, schrieb Michael Hall:
> > > I have a table where I have a serialnumber which shuld be  increased  be
> > > each INSERT.  I know I can use max() to get the highest number, but  how
> > > can I use it in a INSERT statement?
> > 
> > Have a look in the manual for the SERIAL data type.
> > For fields with a SERIAL data type, you can use DEFAULT in an INSERT 
> > statement.
> 
> OK, the SERIAL is now working, but there is ONE problem.
> 
> If the INSERT fails, the SERIAL is in any case increased...
> 
> So this was the reason, why I have tried to use max(serno)  and  add  +1
> the get the next value for "serno".
> 
> Is there a solution for it?

You should read our three FAQ entries about sequences:

        http://www.postgresql.org/docs/faqs.FAQ.html#item4.11.1

-- 
  Bruce Momjian  <[EMAIL PROTECTED]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to