[Firedac] Utiliser un FdScript
Bonjour,
je sèche un peu sur l'utilisation de ce composant et peut être de ses propriétés de plus je voudrais pouvoir en gérer les erreurs.
Voilà le topo je me réfère à la doc trouvée ici
Code:
1 2 3 4 5 6 7 8 9 10 11
|
with FDScript1 do begin
SQLScripts.Clear;
SQLScripts.Add;
with SQLScripts[0].SQL do begin
Add('INSERT INTO Brands VALUES (1, ''Audi'')');
Add('INSERT INTO Brands VALUES (2, ''BMW'')');
end;
ValidateAll;
ExecuteAll;
end; |
en reprenant cet exemple je voudrais faire ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| with FDScript1.SQLScripts do begin
Clear;
with Add do begin
Name := 'root';
SQL.Add('@Audi'); // explicitly call 'Audi' script
SQL.Add('@BMW'); // explicitly call 'BMW' script
end;
with Add do begin
Name := 'Audi';
SQL.Add('INSERT INTO Brands VALUES (1, ''Audi'');');
end;
with Add do begin
Name := 'BMW';
SQL.Add('INSERT INTO Brands VALUES (2, ''BMW'')');
end;
end;
FDScript1.ValidateAll;
FDConnexion1.StartTransaction;
FDScript1.ExecuteAll;
FDConnexion1.Commit; |
ce qui semblerait logique ?
et je voudrai par l'intermédiaire de l'événement OnError du TFdScript obtenir le nom du script en erreur au cas où
Code:
1 2 3 4 5 6
| procedure TForm1.FDScript1r(ASender: TObject;
const AInitiator: IFDStanObject; var AException: Exception);
begin
showmessage(AInitiator.Name+slineBreak+AException.Message);
FDConnexion1.Rollback;
end; |
mais là , j'ai un problème, mon script ne fait ... rien ! :bug:
bien évidement, dans mon programme il ne s'agit pas des mêmes ordres ni table ;) mais le principe est là.
Y voyez vous une erreur de logique ?