Function tservermethods1.executesql (const SQL: string): Boolean;
VaR
D: tfrmdb;
Begin
D: = dbpool. lock;
If assigned (d) then
Begin
Try
Try
D. qry. close;
D. qry. SQL. Clear;
D. qry. SQL. Text: = SQL;
D. qry. execsql;
Result: = true;
Except
On E: exception do
Begin
Result: = false;
Log. writelog ('tservermethods1. executesql' + E. Message );
End;
End;
Finally
Dbpool. Unlock (d );
End;
End
Else
Begin
Result: = false;
End;
End;
Function tservermethods1.querysql (const SQL: string): olevariant;
VaR
D: tfrmdb;
Begin
D: = dbpool. lock;
If assigned (d) then
Begin
Try
Try
D. qry. close;
D. qry. SQL. Clear;
D. qry. SQL. Text: = SQL;
D. qry. open;
Result: = D. DSP. Data;
Except
On E: exception do
Begin
Result: = NULL;
Log. writelog ('tservermethods1. querysql' + E. Message );
End;
End;
Finally
Dbpool. Unlock (d );
End;
End
Else
Begin
Result: = NULL;
End;
End;
Function tservermethods1.querysql2 (const SQL: string): tfdjsondatasets;
VaR
D: tfrmdb;
Begin
D: = dbpool. lock;
If assigned (d) then
Begin
Try
Try
D. qry. close;
D. qry. SQL. Clear;
D. qry. Open (SQL );
Result: = tfdjsondatasets. Create;
Tfdjsondatasetswriter. listadd (result, D. qry );
Except
On E: exception do
Begin
Result: = nil;
Log. writelog ('tservermethods1. querysql2 '+ E. Message );
End;
End;
Finally
Dbpool. Unlock (d );
End;
End
Else
Result: = nil;
End;
Function tservermethods1.savedata (const tablename: string;
Delta: olevariant): Boolean;
VaR
D: tfrmdb;
Errcnt: integer;
Begin
D: = dbpool. lock;
If assigned (d) then
Begin
Try
Try
D. qry. close;
D. qry. SQL. Clear;
D. qry. SQL. Text: = 'select * from' + tablename + 'where 1 = 2 ';
D. qry. open;
D. DSP. applyupdates (delta, 0, errcnt );
If errcnt = 0 then
Result: = true
Else
Result: = false;
Except
On E: exception do
Begin
Result: = false;
Log. writelog ('tservermethods1. savedata' + E. Message );
End;
End;
Finally
Dbpool. Unlock (d );
End;
End
Else
Begin
Result: = false;
End;
End;
Function tservermethods1.savedata2 (const tablename: string;
Delta: tfdjsondeltas): Boolean;
VaR
D: tfrmdb;
Lapply: ifdjsondeltasapplyupdates;
Begin
D: = dbpool. lock;
If assigned (d) then
Begin
Try
Try
D. qry. close;
D. qry. SQL. Clear;
D. qry. SQL. Text: = 'select * from' + tablename + 'where 1 = 2 ';
D. qry. open;
Lapply: = tfdjsondeltasapplyupdates. Create (DELTA );
Lapply. applyupdates (tablename, D. qry. Command );
Result: = lapply. errors. Count = 0;
Except
On E: exception do
Begin
Result: = false;
Log. writelog ('tservermethods1. savedata2 '+ E. Message );
End;
End;
Finally
Dbpool. Unlock (d );
End;
End
Else
Result: = false;
End;
Method definition of Middleware