Re: pg and number of parameters by insert - Mailing list pgsql-general

From Jean-Christian Imbeault
Subject Re: pg and number of parameters by insert
Date
Msg-id 3DEDCCBE.8090404@mega-bucks.co.jp
Whole thread Raw
In response to pg and number of parameters by insert  (pginfo <pginfo@t1.unisoftbg.com>)
List pgsql-general
pginfo wrote:
>
> For example if :
>
> create table table_1 ( filed _1 name, field_2  int, field_3  name);
>
> And if I try to execute:
>
> insert into table_1 values ('f1_value',10);
>
> I do not get any error from pg !!!

The reason is that you did not declare the fields to be "NOT NULL". The
default is to allow null values into the fields unless you specifically
create the columns with the constraint "NOT NULL".

If you want an error to be thrown you need to create your table liek this:

create table table_1 (
   filed _1 text NOT NULL,
   field_2  int  NOT NULL,
   field_3  text NOT NULL
);

Jc



pgsql-general by date:

Previous
From: pginfo
Date:
Subject: pg and number of parameters by insert
Next
From: Richard Huxton
Date:
Subject: Re: Postgresql -- initial impressions and comments