You are not logged in.
Pages: 1
I would like to inform the client when trying to add an already existing record.
But the exception from sqlite3 is not forwarded. The call IRestOrm.add just return zero and the exception can only be seen in the server log.
How could I solve this?
Delphi-11, WIN10
Offline
How could I solve this?
As described in the documentation:
// - on success, returns the new RowID value; on error, returns 0
// - on success, Value.ID is updated with the new RowID
In service you can write the following:
type
TOrmArticle = class(TOrm);
function TArticleService.Add(const pmcItem: TOrmArticle): TID;
var
restServer: TRestServerDB;
begin
Result := -1;
if pmcItem <> Nil then
begin
restServer := GetDBRestServer;
if restServer <> Nil then
Result := restServer.Server.Add(pmcItem, True, False);
end;
end;
In client then the following:
var
data: TOrmArticle;
begin
...
data.IDValue := service.Add(data);
if data.IDValue > 0 then
Or have a look into function AddOrUpdate.
With best regards
Thomas
Offline
I think Trestserverdb.StatementLastException can provide you the sql error that you should return to the client
Offline
Pages: 1