Re: pg and number of parameters by insert

From: pginfo <pginfo(at)t1(dot)unisoftbg(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg and number of parameters by insert
Date: 2002-12-04 09:41:50
Message-ID: 3DEDCDDE.FB06737D@t1.unisoftbg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
Hmm, Ok I try to explain:

If I write: insert into table_1 values ('f1_value',10);

It is error because I try to insert 2 fields in 3-fields table. The reason is that
I can make write error.

If I write : insert into table_1 (field_1,field_2) values ('f1_value',10); It is
no problem because I have specified exact the
inserted fields and I have one missing and it is not NOT NULL.

The problem is that pg do not report the first error.
And as I wrote oracle, MS SQL and mySQL reports correct the error.

I think this bug is potencial ground for many errrs by developing.

regards,
ivan.

Jean-Christian Imbeault wrote:

> pginfo wrote:
> >
> > If I write
> > insert into table_1 (field_1,field_2) values ('f1_value',10);
> > and field_3 is not declared as NOT NULL it will be correct for pg to execute
> > it without any massage.
> >
> > Is it so?
>
> That's right. If you do not declare the column with a constraint of NOT
> NULL, then it is not an error to do:
>
> insert into table_1 (field_1,field_2) values ('f1_value',10);
>
> Why should this query throw an error? You are asking the DB to insert
> values into a row. There are no constraints on any of the columns so the
> DB is quite happy to do what you ask.
>
> If you want to make it mandatory for an insert to specify a value for a
> column then you MUST have a constraint on that column of NOT NULL.
>
> Jc

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message suresh s 2002-12-04 09:43:17 problem starting postgresql i.e postmaster
Previous Message Richard Huxton 2002-12-04 09:38:10 Re: Postgresql -- initial impressions and comments