Procedure Apertura_Data_Base;
Begin
// ------------------------------------------
// Controllo Data-Base già presente
// ------------------------------------------
If FileExists(DBase.DatabaseName) Then
Begin
// ------------------------------------------
// Connessione al Data-Base
// ------------------------------------------
DBase.Connected := True;
// ------------------------------------------
// Uscita
// ------------------------------------------
Exit;
End;
// ------------------------------------------
// Creazione fisica del data base
// ------------------------------------------
Dbase.CreateDatabase;
.........................................
qui' con il componente Query bisognerà creare
tutte le tabelle, trigger ed altro che ci
occorre
.........................................
// ------------------------------------------------------
// Scrive fisicamente i dati e termina la creazione del
// Data-base
// ------------------------------------------------------
Transaction.CommitRetaining;
// ------------------------------------------------------
// Apertura Data-Base
// ------------------------------------------------------
DBase.Connected := True;
End;
Query.SQL.Text := 'SELECT FIRST_NAME, LAST_NAME, SALARY FROM EMPLOYEE WHERE DEPT_NO = :Num';
Query.Params.ByNameAsInteger['Num'] := 623;
Query.Open;
while not Query.EOF do
with Query, Fields do
begin
memo.Lines.Add(format('%s %s, Salary: %f'
,
[ByNameAsString['FIRST_NAME'],
ByNameAsString['LAST_NAME'],
ByNameAsCurrency['SALARY']]));
Next;
end;
Query.Close(etmCommit);
const
Datas : array[1..10] of TARecord = (
(COUNTRY: 'blabla0'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla1'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla2'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla3'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla4'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla5'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla6'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla7'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla8'; CURRENCY: 'blabla'),
(COUNTRY: 'blabla9'; CURRENCY: 'blabla'));
begin
for i := 1 to 10 do
begin
Query.Params.AsString[0] := Datas[i].COUNTRY;
Query.Params.AsString[1] := Datas[i].CURRENCY;
Query.Execute;
// Per performance migliori eseguire un commit ogni circa 1000 record
end;
Query.Close(etmRollback); // Cambiare in etmCommit per applicarlo
end;
Query.QuickScript := True;
Query.SQL.Add('INSERT INTO COUNTRY (COUNTRY,CURRENCY) VALUES (''Test0'',''FFranc'')');
Query.SQL.Add('DELETE FROM COUNTRY WHERE COUNTRY = ''Test0''');
.../...
Query.ExecSQL;
Query.Close(etmCommit);