[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] How to import an empty value(NULL) into database from
From:       Kees Nuyt <k.nuyt () zonnet ! nl>
Date:       2009-07-03 8:09:06
Message-ID: aper459v5v7rf6l16me8cci4q6l9nnret5 () dim53 ! demon ! nl
[Download RAW message or body]

On Fri, 03 Jul 2009 11:12:26 +0800, Kermit Mei
<kermit.mei@gmail.com> wrote:

>Hello, how can I import an empty value into the database from a file.

Using the command line tool to import a csv file, you can't
import NULLs. A line like val1,,val3 would translate in
val1, empty string, val3 in your table row.

>The field may be int or string, if I write "NULL" , then I'll read a
>string "NULL" from it. I hope that I can get an empty value (Eg, an
>empty string whose size() is zero in Qt).
>How can I do ?

Note that NULL is not the same as empty string.
The empty string case is easy, as show above.

Now the NULL case. Assuming 'NULL' is never used as an
actual value in the input, you could specify ..,NULL,... in
the input file and update the table later, like this:

UPDATE mytable SET col2 = NULL WHERE col2 = 'NULL';

>Thanks.
>
>Kermit
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic