I am inserting user details from a file. The file has users seperated by
commas(,)

example of file

manjeet,tom,tim,,john,alexander


Using perl script i am reading the file and seperating user info at commas
and inserting into database.

Now my problem is that i don't want to insert the fourth user which is
blank.

my table definitions are same as in previous mail.

How should i avoid of not inserting data which is not defined in between
commas. I can do that in script. Is there anyway of doing it database level.

Also let me know how do you define NULL in strings.


Thanks

Manjeet
-----Original Message-----
From: Sinisa Milivojevic [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 05, 2002 7:20 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: facing problem with NOT NULL fields


Manjeet writes:
> I created table using following syntax,
>
> create table user (Login_Id varchar(16) NOT NULL, Location varchar(16) NOT
> NULL, PRIMARY KEY (Login_ID));
>
> The above table should not take any null values.
> I tryed inserting some null values eg:
>
> INSERT INTO user (Login_Id,Location) values ("","");
>
> According to me this statement should give error and not work. But still
it
> inserts null values in to the table.
> When the same insert statement is run again, it gives error 1062.
> Plz... suggest how to see that my table does not have any NULL value and
> should i acheive this.
> Or is this a bug.
>
> Thanks
> Manjeet
>


This worked as expected. MySQL inserted the empty  string in both
columns.

You can not insert it again as there is a primary key on one column.

--
Regards,
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Sinisa Milivojevic <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Fulltime Developer
/_/  /_/\_, /___/\___\_\___/   Larnaca, Cyprus
       <___/   www.mysql.com


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to