1

Topic: in a class

Prompt.
There is a method in a class for performance of requests.

procedure TClients.getSQLrequest (sql: string);
begin
with fDataModule_modelwork do begin
try
if IBQuery_SQLrequest. Transaction. Active then IBQuery_SQLrequest.Transaction.Active:=false;
if IBQuery_SQLrequest.active then IBQuery_SQLrequest. Close;
IBQuery_SQLrequest. SQL.Clear;
IBQuery_SQLrequest. SQL.Add (sql);
IBQuery_SQLrequest. Open;
except
on e: exception do
MessageDlg (' the Run error '+#13#10+e.message, mtError, [mbOk], 0);
end;
end;
end;

There are methods which twitch for .
Example:

procedure TClients.getClients_list ();
begin
getSQLrequest (' select ID, NAME from CLIENTS');
end;

As in the given circuit to implement parameterized queries.

select ID, NAME from CLIENTS where id =:id_client
ParamByName (' id_client ').asinteger: = 100;

It would not be desirable to transfer in request variables, for example

getSQLrequest (' select ID, NAME from CLIENTS where id: = ' + id_client);

If sampling big from a heap of tables, request is difficult read
Probably there is something of type such.

clients_query_method () {
Sql. AddQuery (' select ID, NAME from CLIENTS where id =:id_client ')
Sql. AddParam (' id '): =100;
}
getClients_list () {
general_sql (clients_query_method)

2

Re: in a class

wrote:

const AParamValues: TDictionary <string, variant>

And it is possible more detailed,  not absolutely understood

3

Re: in a class

Generally somehow not so
if IBQuery_SQLrequest. Transaction. Active then IBQuery_SQLrequest.Transaction.Active:=false;
If at you transaction is active, it should be completed either Commit or Rollback
And Active=false "on whom god sends it", depending on that there is installed

IBQuery_SQLrequest. SQL.Clear;
IBQuery_SQLrequest. SQL.Add (sql);

It too to replace on idle time

IBQuery_SQLrequest. SQL.text: = sql;

Well and that your request was fulfilled with parameters, it is necessary to provide somehow
1) transmission of these parameters to procedure, for example as it is offered above through TDictionary <string, variant>
(I like a variant simply TList or TObjectList from objects a key-value, but not an essence more...)
2) inside it is necessary to erase old parameters and in a cycle to install values new according to the transferred structure

query.paramByName (key).asVariant: = value;