Re: Why is default value not working on insert?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Chris Hoover <revoohc(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why is default value not working on insert?
Date: 2006-08-08 20:53:33
Message-ID: 20060808205333.GE13311@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 08, 2006 at 04:41:04PM -0400, Chris Hoover wrote:
> I have the following table:

<snip>

> The reason for the null being passed to to_date is this is on of almot 90k
> lines of data we are trying to load, and the script was built to generate
> this code. Since to_date(null,'yyyymmdd') returns a null, why is the
> default not working?

If you try to insert a NULL into a not null column, you get an error.
To trigger the default you either need to omit the column from the
insert statement, or use the DEFAULT keyword.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2006-08-08 21:22:56 clients and libs and versions (oh my)
Previous Message Ian Barwick 2006-08-08 20:53:19 Re: Why is default value not working on insert?