You are not logged in.
It is possible to use this method (TSQLDBConnectionProperties.Execute) on client side?
Basically i need a TSQLTableJson from a external complex table. This table not have a TSQLRecord mapping.
Offline
No, it is not possible, by design.
What you have to do is to create a dedicated service on server side, which may return directly the JSON content as object.
Performance will be very good, and you won't need the DB client to be defined on server side.
Offline
OK. I don't know how work with Service-oriented architecture of mORMot yet, i have to study this.
I can't do this?
IServiceTest = Interface(IInvokable)
['{638398D0-C0B5-4E1B-A46F-D30D26185477}']
function GetSQLTableJSON(ASQL:RawUTF8):TSQLTableJSON;
end;
TServiceTest = class (TInterfacedObject, IServiceTest)
function GetSQLTableJSON(ASQL:RawUTF8):TSQLTableJSON;
end;
or this?
IServiceTest = Interface(IInvokable)
['{638398D0-C0B5-4E1B-A46F-D30D26185477}']
procedure GetSQLTableJSON(ASQL:RawUTF8; out Result:TSQLTableJSON);
end;
TServiceTest = class (TInterfacedObject, IServiceTest)
procedure GetSQLTableJSON(ASQL:RawUTF8; out Result:TSQLTableJSON);
end;
Last edited by Roberto Schneiders (2013-02-11 17:51:45)
Offline
You can not directly access the SynDB classes on the client side.
BUT you can execute a SQL statement, and return a TSQLTableJSON, without the need of deploying a service.
See this method:
/// retrieve a list of members as a TSQLTable (implements REST GET Collection)
// - URI is 'ModelRoot/TableName' with GET method
// - SQLSelect and SQLWhere are encoded as 'select=' and 'where=' URL parameters
// (using inlined parameters via :(...): in SQLWhere is always a good idea)
// - server must return Status 200/HTML_SUCCESS OK on success
function TSQLRestClientURI.List(const Tables: array of TSQLRecordClass;
const SQLSelect, SQLWhere: RawUTF8): TSQLTableJSON;
I suppose this is what you need.
Offline
I tried this method, but not work for me.
My code is like this:
Table := Client.List([], 'Select * from SGRUSR01');
The result is nil.
I dont have de TSQLRecord classes for this tables.
You have another idea?
... and about those codes i posted (Services), its possible do that?
Offline
You could try something like:
var
JSONBuffer: RawUTF8;
procedure example;
var
Table: TSQLTable;
Rows: ISQLDBRows;
begin
Rows := Client.Execute('select * from SGRUSR01',[]);
fJSONBuffer := Rows.FetchAllAsJSON(false);
Table := TSQLTableJSON.Create([],'',pointer(fJSONBuffer),length(fJSONBuffer));
...
Offline
I don't found the "execute" method in my client class (TSQLHttpClient).
Offline
@esmondb You will need the SynDB* units on client side, also with the corresponding drivers... so perhaps not exactly what Robert expected!
I don't found the "execute" method in my client class (TSQLHttpClient).
Yes, it does not exist, for the reason it is not a TSQLRestClient, but a TSQLDBProperties.
I'm working on a new sample, showing how to implement this feature without the ORM.
Basicaly, a "SynDBExplorer" in remote mode.
And perhaps in the future adding this remote mode to SynDBExplorer.
Offline
I've just added a new "16 - Execute SQL via services" sample.
See http://synopse.info/fossil/dir?name=SQL … a+services
This is a remote connection to any DB server.
The latest connection settings are persisted on the local folder, within a JSON .settings file.
The list of tables is retrieved from the database, for direct "SELECT * FROM" statements.
Returned data is displayed within a mORMot "grid".
It uses a sicClientDriven service, which is pretty common for handling a network connection property per client.
Some optimization is still needed - I'll for instance add a RawJSON new string type, which won't be escaped when transmitted (as done for a classic RawUTF8 function result).
A TSQLDBProperties cache on server side should better be implemented, since one instance is created per client access thread.
But I suppose it is a good example of Client-Server interfaces with mORMot.
Also showing how to use a TSQLTableJSON.
I also included some new wrappers in the framework (both RESTful core and UI layer).
Offline
Thank you very much. I will check this out.
Offline