You are not logged in.
Pages: 1
Hi,
I used some parts of this beautiful framework to implement a REST client for our custom server (NOT a mORMot Server).
This server exposes some services as JSON structures.
In short, i used
- TWinHTTP to invoke the services
-_JSONFast to parse the response
- TSQLTableJSON.CreateFromTables([TSQLMyResponseContentMappedRecord], '', MyJsonContent) to map the response to a TSQLTable made of specific record structures.
So, now I have a MyTable: TSQLTableJSON whose rows can be mapped to TSQLMyResponseContentMappedRecord structures:
type
TSQLMyResponseContentMappedRecord = class(TSQLRecord)
private
fMyFirstField: RawUTF8;
fMySecondField: Integer;
published
property MyFirstField: RawUTF8 read fMyFirstField write fMyFirstField;
property MySecondField: Integer read fMySecondField write fMySecondField;
end;
I know I can read it this way, with Late Binding:
var
CurrentRow: Variant;
while MyTable.Step(False, @CurrentRow) do
begin
...CurrentRow.MyFirstField...
...CurrentRow.MySecondField...
...etc...
end;
Is there a way to read the current row with EARLY binding, so that I'm sure that accessing a CurrentRow.WrongField yelds a compile-time error?
Thank you.
Offline
Thank you, this is exactly what I needed.
Analyzing the code in CreateAndFillPrepare I chose to separate
Create and FillPrepare because I already have the TSQLTableJSON object I used to parse the JSON,
and also because I need that object to have the rowcount.
Or is there a better way to get the RowCount?
Offline
Using TSQLTableJSON to get the RowCount is the preferred way, since it is optimized for all flavors of input format (e.g. in non expanded mode, there is an optional "rowCount": field in the input JSON, which speed up the whole process a lot in case of huge resultset).
Online
Pages: 1