[yunqa.de] Field sizes - SQLite tables

  • From: Hal Corbould <hal.corbould@xxxxxxxxxxxx>
  • To: Junker R - via Freelist <yunqa@xxxxxxxxxxxxx>
  • Date: Sun, 10 May 2009 13:13:18 +1000

Referring to my post below, the DISQLite3 help file answered my concern about field sizes - fields/columns are dynamically sized, and not rigidly typed. Because SQLiteSpy accepted my MySQL table create statement extracted from the MySQLdump.exe *.sql file , I assumed that the two currency fields were limited to 3 and 30 chars respectively. Not so, I now understand, much better.


I'd still like some help on the 20 char limit to any text column as exhibited in DISQLite3_ClientDataSet_Grid.dpr. Might be something to do with WideStrings and the TStringField.Size property mentioned in Ralf's reply to the Yeoh Ray Mond's post of 5 April 2008?


***** Original post *****

I am transferring eight tables in a MySQL database intended for the public domain to SQLite. I am using DISQLite3. I am concerned about table field design and sizes.

I started by re-creating the simplest table in the MySQL database - a list of currency codes and names.

I created a new database and then a table using SQLiteSPy 1.8.9.
create table tcurr (
currcode char(3) not null unique default ZZZ,
currname char(30) not null default Name,
primary key (currcode)
)

I populated the table with eg
insert into tcurr (currcode,currname) values ('CAD','Canadian dollar');
insert into tcurr (currcode,currname) values ('USD','US dollar');
insert into tcurr (currcode,currname) values ('HKD','Hong Kong dollar78201234567830');
insert into tcurr (currcode,currname) values ('AUD','Australian dollar');
insert into tcurr (currcode,currname) values ('EUR','Euro');

All ok.

I then revised DISQLite3_ClientDataSet_Grid.dpr to read in the new tcurr table and display it for additions and editing. I found that while I could add new 3-char codes, the currname field would display only 20 chars (the HKD name was truncated), and would not accept any new currname text longer than 20 chars.

Using SQLiteSpy, I added these new currencies:
insert into tcurr (currcode,currname) values ('ZLN','Long dollar2345678201234567830'); insert into tcurr (currcode,currname) values ('ZLX','Extended dollar6782012345678301234567840'); insert into tcurr (currcode,currname) values ('ZLXABC','Extended dollar6782012345678301234567840');

These additions were successfully displayed in SQLIteSpy.

Returning to DISQLite3_ClientDataSet_Grid.exe, all currency names longer than 20 chars were truncated to 20 chars, but the six char currcode added using SQLiteSpy was fully displayed.

I then manually added one extra currency using DISQLite3_ClientDataSet_Grid.exe. This test allowed me to input QWERTY as the currcode and this was accepted when I clicked the Apply Updates button.

Could you please help with these questions:

1) Why when using SQLiteSpy will the table accept and display a currcode longer than three chars, and/or a currname longer than 30 chars?

2) Why will DISQLite3_ClientDataSet_Grid.exe accept and then display all six chars of the deliberately incorrect currency code ZLXABC when this field is set to be three chars?

3) Why will DISQLite3_ClientDataSet_Grid.exe not accept or display the full thirty chars of the currname?

Thanks.



--
Hal Corbould
------------------------------------------------------------------------
Postal:   PO Box 495, Spit Junction NSW 2088 Australia
Street:   1A Stanton Road, Mosman NSW
Phone:    02  9969 3186   Fax:    02  9960 6486
Mobile:   0412 035 576    Email:    hal.corbould@xxxxxxxxxxxx
GPS location:   S33.821033   E151.249317

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



Other related posts: