Page 1 of 1

SQLite primart key value after post

Posted: Fri 26 Nov 2010 19:27
by Andrey
Have another trouble with the SQLite.
I use autoincrement primary key fields and after adding new record with 'Append'/'Post' methods of TUniQuery the value of Primary key field is '0'. So i need to refresh dataset to aquire actual value.

Posted: Mon 29 Nov 2010 08:16
by AlexP
Hello,

I can not reproduce the problem.

Please try to create the following table:

CREATE TABLE test
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
text VARCHAR(50)
)

and insert data into it like this:

UniQuery1.SQL.Clear;
UniQuery1.SQL.Text := 'SELECT * FROM test';
UniQuery1.Open;
UniQuery1.Append;
UniQuery1.FieldByName('text').AsString:= 'test';
UniQuery1.Post;
ShowMessage(UniQuery1.FieldByName('id').AsString);

you should see correct data from the ID field.

I have tested it on the 3.50.0.13 version of UniDAC.

Posted: Mon 29 Nov 2010 09:27
by Andrey
I've compared your example (it works) with my. I use these syntax:

Code: Select all

CREATE TABLE "ProductType" (
    "ProductType_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    "ProductType_name" VARCHAR(100)
)
It seems that quotes make difference. With field name in quotes id is not returned after 'Post' and without them it works well.

I think it should works with quotes too.

Posted: Mon 29 Nov 2010 09:53
by AlexP
Hello,

Thank you for the information.
We have reproduced the problem.
We will notify you as soon as we have any results.

Posted: Wed 01 Dec 2010 13:37
by bork
Hello

We have fixed this problem. This fix will be included in the next UniDAC build.