[yunqa.de] Create table with default 2

  • From: edoardo falzetti <edoardo.falzetti@xxxxxxxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Thu, 18 Aug 2011 10:45:22 +0200

Hallo!
The error is already in your demo application DISQLite3_World_ClientDataSet.dpr

You can verify the error in  your demo application
DISQLite3_World_ClientDataSet.dpr.

In it just change the following create:

  SQL_CREATE_COUNTRIES =
    'CREATE TABLE Countries (' + #13#10 +
    '"ID" INTEGER PRIMARY KEY,' + #13#10 +
    '"Name" TEXT UNIQUE,' + #13#10 +
    '"Background" TEXT,' + #13#10 +
    '"Area" INTEGER DEFAULT 0,' + #13#10 +       //<<<<<<  modified: added
DEFAULT
    '"Population" INTEGER,' + #13#10 +
    '"Birth Rate" FLOAT,' + #13#10 +
    '"Life Expectancy" FLOAT,' + #13#10 +
    '"Flag" BLOB' + #13#10 +
    ')';


and then:

1) insert new record without editing Area
2) post
3) apply updates
4) delete record
5) apply updates --> Error
or
4) edit record
5) apply updates --> Error

This is what happens in my transactions where sometimes i have hidden fields
which are for future use and are initialized with the DEFAULT clause.
As all other fields are initialized by the user or, if not,  by the program i
saw the error in the field wich was initialized with the default clause.


But..
But now trying with your demo i found out that you get the same error even
without the DEFAULT clause if you:



1) insert new record WITHOUT editing Area or Population or ...
2) post
3) apply updates
4) delete record
5) apply updates --> Error
or
4) edit record
5) apply updates --> Error


Just because you already have the project to verify the problem i don't try now
to extract it from my application.

But...

But looking at the errors:

  'Record changed by another user'
  'unable to find record. No key specified'

i now remember that these are the very SAME ERRORS i got some months ago but in
a different context.
At that time i made a project to send you but then i didn't because i found a
solution.
I do not know if it can be of any help, anyway, with the next message i send you
that project and the solution i found.

Thanks edoardo

PS:
- i'be been testing the last version of Disqlite3 with D7. I got the same wrong
behavior.
- as i told you, the error is the WHERE part of the sql instruction where you
use all the fields but some are not in the state you think they are and the
instruction cannot locate the record. I imagine you use all the fields in the
WHERE because there could be no primary key for the table. But when such
primary key exists, could it not be better to use only the key field in the
WHERE ?
-in demo application DISQLite3_World_ClientDataSet.dpr the DBNavigator wasn't
visible; i had to change the align property of edtbackground and DBNavigator in
order to use the demo.


-- 
edoardo falzetti


_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: