SQLite : how to read / write the int64 field?
Posted: 11.06.2007, 12:54
Hi, everybody!
I create a SQLite database like this:
CREATE TABLE [test] (
[ID] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[MyValue] INTEGER NULL,
[MyString] TEXT NULL
)
then, i put a TZTable (named to "tblSQLite") on a new TForm, set it to the correct database.
drop a TButton on the TForm, set it event like this:
tblSQLite.Append;
TLargeintField( tblSQLite.FieldByName('MyValue') ).Value := 9069649169573862877;
// TLargeintField( tblSQLite.FieldByName('MyValue') ).Value := 9069649169; // use a small Integer also throw exceptions
tblSQLite.Post;
but, when i run it, it told me that :
"9.06964916957386E018 is not a valid value for field 'MyValue'. The allowed range is 9.22337203470729E018 to 0."
as everyone know, sqlite treat INTEGER as int64, but why here become a DOUBLE (seem like a double)?
also, when i use the fields editor to add all fields, ID and MyValue be treat as TIntegerField,
if ID and MyValue larger than Integer, how to read and write them?
Excuse for my poor english
I create a SQLite database like this:
CREATE TABLE [test] (
[ID] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[MyValue] INTEGER NULL,
[MyString] TEXT NULL
)
then, i put a TZTable (named to "tblSQLite") on a new TForm, set it to the correct database.
drop a TButton on the TForm, set it event like this:
tblSQLite.Append;
TLargeintField( tblSQLite.FieldByName('MyValue') ).Value := 9069649169573862877;
// TLargeintField( tblSQLite.FieldByName('MyValue') ).Value := 9069649169; // use a small Integer also throw exceptions
tblSQLite.Post;
but, when i run it, it told me that :
"9.06964916957386E018 is not a valid value for field 'MyValue'. The allowed range is 9.22337203470729E018 to 0."
as everyone know, sqlite treat INTEGER as int64, but why here become a DOUBLE (seem like a double)?
also, when i use the fields editor to add all fields, ID and MyValue be treat as TIntegerField,
if ID and MyValue larger than Integer, how to read and write them?
Excuse for my poor english