Re: Inserting Default Values - Mailing list pgsql-general

From Doug McNaught
Subject Re: Inserting Default Values
Date
Msg-id m366596wit.fsf@varsoon.denali.to
Whole thread Raw
In response to Inserting Default Values  (Mike Barrett <mike@daboyz.org>)
List pgsql-general
Mike Barrett <mike@daboyz.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

pgsql-general by date:

Previous
From: postgresql@fruru.com
Date:
Subject: Re: Inserting Default Values
Next
From: Tom Lane
Date:
Subject: Re: 7.1.3 : copy from stdin is very slow!