You are not logged in.
Pages: 1
Hi AB i have a delphi question i can not solve by myself:
I'm writing an interface with Mormot. One Param is RawJSON containing an array auf Strings.
I wan't to give the Strings of this array as Params to:
TSQLDBConnectionProperties.Execute(const aSQL: RawUTF8; const Params: array of const
so i have to create an dynamic array of const and add some RawUtf8 Values to it.
But i dont' know how to do this ?!
var
pArray : array of const; // does not work
pArray : TVarRec; // does
begin
Connection.Execute('select * from tabelle where id in [?,?,?,?]', pArray)
the ? are generated for every array item.
Can you help me how to code this ?
Rad Studio 12.1 Santorini
Offline
May be i found the solution. But it looks very complicated ?!
function Getxyz(cinst AStatus : RawJSON) : RawJSON;
var
Stmt : ISQLDBRows;
LAStatus : array of TVarRec;
LVStatus : variant;
i : integer;
sFragezeichen : RawUtf8;
begin
LVStatus := _JsonFast(AStatus);
SetLength(LAStatus, DocVariantData(LVStatus).Count);
sFragezeichen := '';
for i := 0 to DocVariantData(LVStatus).Count-1 do begin
if Length(sFragezeichen) > 0 then
sFragezeichen := sFragezeichen + ',';
VariantToVarRec(DocVariantData(LVStatus).Values[i], LAStatus[i]);
sFragezeichen := sFragezeichen + '?';
end;
Stmt := Connection.Execute('select * from tabelle where status in (' + sFragezeichen + ')', LAStatus);
exit(Stmt.FetchAllAsJSON(false));
end;
is there an easier way ?
Rad Studio 12.1 Santorini
Offline
You can use ExecuteInlined() with the parameters inlined with
:("string"):
instead of the ?.
See FormatUTF8() for instance, and the information about inlined parameters in http://synopse.info/files/html/Synopse% … ml#TITL_61
Offline
TYVM
Sometimes i have a board in front of the head.
Rad Studio 12.1 Santorini
Offline
Pages: 1