Re: [sqlite] Trouble inserting null value from txt file

2011-04-08 Thread craf
>-Mensaje original-
>De: Jean-Christophe Deschamps 
>Reply-to: General Discussion of SQLite Database
>
>Para: General Discussion of SQLite Database 
>Asunto: Re: [sqlite] Trouble inserting null value from txt file
>Fecha: Fri, 08 Apr 2011 19:40:07 +0200

>It's impossible when you use standard sqlite3 command line utility. In
>your particular case you have 2 options: either write your own
>application that will recognize some kind of value as null and insert
>it instead of plain text, or you can use temporary table like this:

>Another way is to use Pavel's suggestion to reserve some rare arbitrary 
>string and use an insert trigger to convert the value into actual SQL null.

>BTW, beware that triggers can slow down insert rate seriously.


Hi jean

Thanks and I will consider.

Regards.

Cristian

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Trouble inserting null value from txt file

2011-04-08 Thread craf
>-Mensaje original-
>De: Pavel Ivanov 
>Para: General Discussion of SQLite Database 
>Cc: craf 
>Asunto: Re: [sqlite] Trouble inserting null value from txt file
>Fecha: Fri, 8 Apr 2011 13:34:25 -0400

> There is a way to insert null values from a file without specifying it
> in?

>It's impossible when you use standard sqlite3 command line utility. In
>your particular case you have 2 options: either write your own
>application that will recognize some kind of value as null and insert
>it instead of plain text, or you can use temporary table like this:

>CREATE TABLE tmp (name text);

>Then import data (without first column) into it, then execute the
>following statement:

>insert into t (name) select name from tmp;


>Pavel

Hi Pavel.

Excellent solution!, thank you very much for her.

Regards.

Cristian

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Trouble inserting null value from txt file

2011-04-08 Thread Jean-Christophe Deschamps

>It's impossible when you use standard sqlite3 command line utility. In
>your particular case you have 2 options: either write your own
>application that will recognize some kind of value as null and insert
>it instead of plain text, or you can use temporary table like this:

Another way is to use Pavel's suggestion to reserve some rare arbitrary 
string and use an insert trigger to convert the value into actual SQL null.

BTW, beware that triggers can slow down insert rate seriously.


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Trouble inserting null value from txt file

2011-04-08 Thread Pavel Ivanov
> There is a way to insert null values from a file without specifying it
> in?

It's impossible when you use standard sqlite3 command line utility. In
your particular case you have 2 options: either write your own
application that will recognize some kind of value as null and insert
it instead of plain text, or you can use temporary table like this:

CREATE TABLE tmp (name text);

Then import data (without first column) into it, then execute the
following statement:

insert into t (name) select name from tmp;


Pavel


On Fri, Apr 8, 2011 at 1:28 PM, craf  wrote:
> Hi.
>
> I'm new to SQLite and I am looking for a way to insert null data from
> txt file.
>
> My database is:
>
> CREATE TABLE t (id integer primary key autoincrement,
>                name text);
>
> The data in the file data.txt are:
>
> null,"Peter"
> null,"Xavier"
>
>
> The problem occurs when I import the data:
>
> sqlite>.separator ','
> sqlite>.import data.txt t
>
> The error that throws me is:
>
> "Error: datatype mismatch"
>
> It is due to null, but I tried to put as:
>
> "null","Peter"
> 'null','Peter'
> '','Peter'
>  ,'Peter'
>
> But none of these options recognizes me.
>
> There is a way to insert null values from a file without specifying it
> in?
>
> Sorry for my English!
>
> Regards
>
> Cristian
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Trouble inserting null value from txt file

2011-04-08 Thread craf
Hi.

I'm new to SQLite and I am looking for a way to insert null data from
txt file.

My database is:

CREATE TABLE t (id integer primary key autoincrement,
name text);

The data in the file data.txt are:

null,"Peter"
null,"Xavier"


The problem occurs when I import the data:

sqlite>.separator ','
sqlite>.import data.txt t

The error that throws me is:

"Error: datatype mismatch"

It is due to null, but I tried to put as:

"null","Peter"
'null','Peter'
'','Peter'
 ,'Peter'

But none of these options recognizes me.

There is a way to insert null values ​​from a file without specifying it
in?

Sorry for my English!

Regards

Cristian

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users