Re: Inserting Default Values

From: Doug McNaught <doug(at)wireboard(dot)com>
To: Mike Barrett <mike(at)daboyz(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Inserting Default Values
Date: 2002-02-07 17:18:18
Message-ID: m366596wit.fsf@varsoon.denali.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike Barrett <mike(at)daboyz(dot)org> writes:

> The problem here is that no matter what I do, I can't get it to
> just take the default value for id. I've tried leaving a blank, followed
> by a comma as in:
>
> sql=> insert into test values (,'blah');

This was just discussed a week or two ago. The proper syntax is:

INSERT INTO test (name) VALUES ('blah');

> But that errors out. I've messed with using the nextval()
> function, but that seems to run before the actual query is run, so if
> there is an error in the query, my sequence goes to the next value
> anyways. This won't work for me because if the query fails, I don't want
> to have gaps in id #'s.

You *will* have gaps in IDs if you use sequences and have rolled-back
transactions. See the docs and the FAQ.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike Barrett 2002-02-07 17:25:10 Inserting Default Values
Previous Message postgresql 2002-02-07 17:17:08 Re: Inserting Default Values