Topic: Read data from external DB
I create a SQL script to transfer data from another database to the current one.
How can I retrieve an ID if they do not have serial numbers.
My Visual Database → Script → Read data from external DB
I create a SQL script to transfer data from another database to the current one.
How can I retrieve an ID if they do not have serial numbers.
Hi,
If there is no serial number then I don't know. )))
How can we help you if we don't know what a serial number is and what tables you have? And what are we talking about?
It is possible more in detail?
I create a SQL script to transfer data from another database to the current one.
How can I retrieve an ID if they do not have serial numbers.
подключитесь к другой базе данных SQLite
connect to another SQLite database
SQLExecute('ATTACH DATABASE ''d:\testDB.db'' as ''TEST''');
использовать в программе
use in the program
SQLExecute('SELECT TEST.person.lastname FROM TEST.person');
In this way, only one record is extracted.
I want to read the whole table and save it in another database.
The ID numbers are not consecutive because there are deleted records.
In this way, only one record is extracted.
I want to read the whole table and save it in another database.
The ID numbers are not consecutive because there are deleted records.
1. Подключаетесь к БД
2. Получаете общее число записей
3. С помощью (FOR) перебираете все записи ( получить запись из таблицы1 -- создать новую запись в таблице2 )
1. Connect to the database
2. Get the total number of records
3. Use (FOR) to iterate through all the records ( get a record from table1 -- create a new record in table2 )
In this way, only one record is extracted.
I want to read the whole table and save it in another database.
The ID numbers are not consecutive because there are deleted records.
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
tmpDataSet: TDataSet;
begin
SQLExecute('ATTACH DATABASE ''test.db'' as ''TEST''');
SQLQuery('SELECT * FROM TEST.klienti ',tmpDataSet);
try
while not tmpDataSet.EOF do
begin
SQLExecute('INSERT INTO kl (nameklient) VALUES ('''+escape_special_characters(tmpDataSet.FieldByName('klient').asString) +''')');
tmpDataSet.Next;
end;
finally
tmpDataSet.Free;
end;
end;
My Visual Database → Script → Read data from external DB
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi