Hi Mathias,
Thank you very much for your patience and extremely kind help.......................................................
Still couldn't get it working fully. Script syntax errors are corrected. However I get error on running the script. Most likely I'm doing things wrong.
1. I rename old db (with data) to sqliteData
2. On SQLite Compare utility, I put the old db that's renamed to sqliteData to left and new db (blank) sqlite to right.
3. Generate script left --> to right.
Is "Comparison error" something to be concerned about?
Here is the script generated by SQLite Compare:
BEGIN TRANSACTION;
CREATE TABLE issueFilter
(
id INTEGER PRIMARY KEY ASC AUTOINCREMENT,
issueFilter TEXT
);
-- Creating table Issues from scratch (simple ALTER TABLE is not enough)
CREATE TABLE temp_Issues_1848543519
(
id INTEGER PRIMARY KEY ASC AUTOINCREMENT,
issueDate TEXT,
issueName TEXT NOT NULL,
issueReoprted TEXT,
issueDesc TEXT,
id_Application INTEGER,
id_issueFilter INTEGER,
issueFilterValue TEXT,
FOREIGN KEY (id_Application) REFERENCES Application(id) ON DELETE CASCADE,
FOREIGN KEY (id_issueFilter) REFERENCES issueFilter(id)
);
-- Copying rows from original table to the new table
INSERT INTO temp_Issues_1848543519 (id,issueDate,issueName,issueReoprted,issueDesc,id_Application,id_issueFilter,issueFilterValue) SELECT id,issueDate,issueName,issueReoprted,issueDesc,id_Application,id_issueFilter,issueFilterValue FROM Issues;
-- Droping the original table and renaming the temporary table
DROP TABLE Issues;
ALTER TABLE temp_Issues_1848543519 RENAME TO Issues;
COMMIT TRANSACTION;
And here is the MVD version of the above script:
procedure Form1_Button7_OnClick (Sender: TObject; var Cancel: boolean);
var SqliteTr: TDBXSqliteTransaction;
begin
//Initiate the transaction
SqliteTr := BeginSQLiteTransaction;
//SQL command 1
SQLExecute('CREATE TABLE issueFilter'+
'('+
'issueFilter TEXT'+
')');
//SQL command 2
SQLExecute('CREATE TABLE temp_Issues_1848543519'+
'('+
'id INTEGER PRIMARY KEY ASC AUTOINCREMENT,'+
'issueDate TEXT,'+
'issueName TEXT NOT NULL,'+
'issueReoprted TEXT,'+
'issueDesc TEXT,'+
'id_Application INTEGER,'+
'id_issueFilter INTEGER,'+
'issueFilterValue TEXT,'+
'FOREIGN KEY (id_Application) REFERENCES Application(id) ON DELETE CASCADE,'+
'FOREIGN KEY (id_issueFilter) REFERENCES issueFilter(id'+
'))');
//SQL command 3
SQLExecute('INSERT INTO temp_Issues_1848543519 (id,issueDate,issueName,issueReoprted,issueDesc,id_Application,id_issueFilter,issueFilterValue) '
+'SELECT id,issueDate,issueName,issueReoprted,issueDesc,id_Application,id_issueFilter,issueFilterValue FROM Issues;');
//SQL command 4
SQLExecute('DROP TABLE Issues;');
//SQL command 5
SQLExecute('ALTER TABLE temp_Issues_1848543519 RENAME TO Issues;');
//Commit the SQLTransaction
CommitSQLiteTransaction(SqliteTr);
end;
When I run it and click on db update button (Button7) I get the following error:
I comment out :
SQLExecute('CREATE TABLE issueFilter'+
'('+
'issueFilter TEXT'+
')');
Then script runs without error. After, I rename sqliteData.db to sqlite.db and copy over blank (new app db). This time I get error saying there is no such table issueFilter....