#1 2016-05-25 14:15:09

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Question : Problem with addorupdate() using two rest database context

Hi,

Imagine the next scenario :

Pseudo Code :

type

DiskDatabase = TSQLRestServerDB;
MemDatabase = TSQLRestServerFullMemory;

TName = class(TSQLRecord)
   private
     fnam : RawUTF8;
   published 
     property Nam : RawUTF8 read fnam write fnam;
end;

end;

Two database context with one SQLRecord class inside (Two Databases share the same model). No problems here.

Suppose this :

var
  Nam : TName;
  MemoryContext : TSQLRestServerFullMemory;
  DiskContext : TSQLRestServerDB;
begin
  //Create two context one from memory and another from disk file and search one TName record on Memory (we added one) database (WHERE Name = Turrican)
  //... Context creation Skipped ...
  Nam := TName.CreateAndFillPrepare(MemoryContext , 'Name=?', ['Turrican'])
  if Nam.Fillone
  begin
    //We insert TName record to disk file database
    DiskContext.AddOrUpdate(Nam);
  end;
end;
  DiskContext.AddOrUpdate(Nam); //Doesn't fail but doesn't insert or update the record.

The previous code tries to insert one record from a memory server to a physical database server. This isn't working...

Did you know what fails to make this approach of the previous pseudo-code?

Thanks!

Last edited by turrican (2016-05-25 14:20:38)

Offline

#2 2016-05-25 18:19:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Question : Problem with addorupdate() using two rest database context

Use a TSynUniqueIdentifierGenerator on each client side.

Offline

Board footer

Powered by FluxBB