On 9 Feb 2012, at 5:42pm, yesnid wrote:
> CREATE TABLE IF NOT EXISTS Exports (id varchar(50) PRIMARY
> KEY NOT NULL,start_time integer,end_time
> integer,data_source_id varchar(50),format
> integer,percent_complete integer,size integer,comment
>
> varchar(50),user_id varchar(50),state
> integer,friendly_name varchar(50),download_count
> integer,mark_for_delete integer,udn varchar(50));
>
> and here is my insert:
>
> INSERT INTO Exports
> VALUES('d006dacf-3134-45b6-828b-0860738e4029',1311178875028,1311178935028,'dvd-1',2001,0,0,'/*NoComment*/','matt',1337,'d006dacf-3134-45b6-828b-0860738e4029',0,0,'406b8555-5ae5-496d-844c-2f839e19eb75');
>
> what winds up in the database for start and end time is:
>
> 1213849748
>
> which is what the number 1311178875028 becomes if you cast it to an int
That is very good diagnostic information which helps us a lot in figuring out
your problem.
Your handling of integers is fine. Try the same commands using the SQLite3
command-line tool and you'll find that your commands work perfectly:
SQLite version 3.7.7 2011-06-25 16:35:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE IF NOT EXISTS Exports (id varchar(50)
PRIMARY
...> KEY NOT NULL,start_time integer,end_time
...> integer,data_source_id varchar(50),format
...> integer,percent_complete integer,size integer,comment
...> varchar(50),user_id varchar(50),state
...> integer,friendly_name varchar(50),download_count
...> integer,mark_for_delete integer,udn varchar(50));
sqlite> INSERT INTO Exports
...>
VALUES('d006dacf-3134-45b6-828b-0860738e4029',1311178875028,1311178935028,'dvd-1',2001,0,0,'/*NoComment*/','matt',1337,'d006dacf-3134-45b6-828b-0860738e4029',0,0,'406b8555-5ae5-496d-844c-2f839e19eb75');
sqlite> SELECT start_time FROM Exports;
1311178875028
So the fault is in your application. My guess is that your are retrieving the
result of the SELECT into smaller integer fields than you're realised: that the
truncation is happening after the correct number is retrieved from the database.
Incidentally, the columns you've designated as 'varchar(50)' are being handled
as TEXT because SQLite doesn't have a varchar type. So do not rely on SQLite
enforcing any 50-character limit.
Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users