On Thu, Dec 13, 2001 at 09:50:11AM +0530, sreedhar wrote:
> CREATE TABLE tblTEST(field1 VARCHAR(20) NOT NULL, field2 VARCHAR(20) NOT
> INSERT INTO tblTEST (field1) VALUES (NULL);
> INSERT INTO tblTEST (field2) VALUES (NULL);
> INSERT INTO tblTEST (field1,field2) VALUES (NULL,'HELLO');
> not accepting NULL values; but
> INSERT INTO tblTEST (field1) VALUES ('HELLO');
> This statement inserting empty value in 'field2'.
> field1 field2
> so how can we make INSERT statement to fail if value of NOT NULL field is
> not supplied.
MySQL supplies a default value for any field that isn't specified.
You should verify that you have a value for field1 before issuing
the insert. You'd have to handle an error anyway.
> ----- Original Message -----
> From: "Paul DuBois" <paul@stripped>
> To: "sreedhar" <sreedhar@stripped>; "mysql"
> Sent: Wednesday, December 12, 2001 11:25 PM
> Subject: Re: NOT NULL field accepting NULL
> > At 7:12 PM +0530 12/12/01, sreedhar wrote:
> > >Hi All,
> > >
> > >In MySQL, Even i declared a field as NOT NULL it is accepting nulls .What
> > >might be the
> > >problem. please let me know.
> > >
> > >regards,
> > >sreedhar
> > That's not enough information.
> > Let's see the CREATE TABLE statement, a sample INSERT statement, and
> > the resulting record.