-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.pas
More file actions
31 lines (25 loc) · 1.07 KB
/
Copy pathexamples.pas
File metadata and controls
31 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Here is one example:
//This is the original code which I was using for a long time
DataModule1.fdtGlobal.StartTransaction;
try
with DataModule1.fdqGlobal do
begin
close;
sql.Clear;
sql.Add('delete from foobar where foo=:P1 and bar=:P2');
ParamByName('P1').Value := 'foo';
ParamByName('P2').Value := 'bar';
ExecSQL;
end;
DataModule1.fdtGlobal.Commit;
except
DataModule1.fdtGlobal.Rollback;
raise;
end;
//Instead of this long code, you can use component, by calling the ExecQuery procedure and you will get the same result.
DataModule1.brxTransWrapper1.ExecQuery('delete from foobar where foo=:P1 and bar=:P2',['foo','bar']);
//Similar is with opening the resultset.
DataModule1.brxTransWrapper1.OpenQuery('select * from foobar where foo=:P1 and bar=:P2',['foo','bar']);
//In this procedure, transaction is started, if there is no error, memory table is getting the resultset and the transaction is committed then you can use memory table to navigate through data, for example:
if DataModule1.fdMemTable.fieldbyname('foo').asstring ='foo' then
...