#1 2014-03-07 09:37:59

tech
Member
Registered: 2014-01-13
Posts: 107

Unregister virtual table

Hi all,

I've to load data from a mysql external table and make some changes in the sqlite3 (without impacting mysql one) and finally to put records on an other MSSql external table. Is there a possibilty to unregister mysql table just after pumping data and to continue work only with sqlite3 ?

Thx.

Offline

#2 2014-03-07 09:53:48

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

Re: Unregister virtual table

AFAIR this is not feasible, nor wished.

You can use dedicated sub-class, then register it with a dedicated external engine and its exact MS SQL table name, then do your "pumping", and continue to work with the main SQlite3 class.

Offline

#3 2014-03-07 10:39:19

tech
Member
Registered: 2014-01-13
Posts: 107

Re: Unregister virtual table

Ok, I've created a sub-class named TSQLMyClass derived from TSQLClass that have external table but i dont know how to pump data from the sub-class into the mother one !

Offline

#4 2014-03-07 12:12:26

tech
Member
Registered: 2014-01-13
Posts: 107

Re: Unregister virtual table

I've found the fillfrom() method but it doesn't copy all fields. This code copy records with empty fields :

var myRec : TSQLmyClass;
    sqlRec: TSQLClass;
  Results: TIntegerDynArray;
begin
  try
        myRec := TSQLmyClass.CreateAndFillPrepare(globalClient, '');
        sqlRec:= TSQLClass.Create;
        if globalClient.TransactionBeginRetry(TSQLClass, 20) then
        try
          globalClient.BatchStart(TSQLClass);
          while myRec.FillOne do
          begin
            sqlRec.FillFrom(myRec);
            globalClient.BatchAdd(sqlRec, true);
          end;
          globalClient.BatchSend(Results);
          globalClient.Commit();
        except
          globalClient.RollBack();
        end;
      finally
        myRec .Free;
        sqlRec.Free;
      end;
end;

Offline

#5 2014-03-07 13:40:15

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

Re: Unregister virtual table

As stated by the documentation of TSQLRecord.FillFrom():

source object must be a parent or of the same class as the current record

If thjs is not the case (i.e. TSQLClass is not tied to TSQLmyClass), you can use a temporary JSON conversion:

  sqlRec.FillFrom(myRec.GetJSONValues(true,true,soInsert));

Offline

#6 2014-03-07 15:10:39

tech
Member
Registered: 2014-01-13
Posts: 107

Re: Unregister virtual table

Thx Arnaud, it works perfectly.

Offline

Board footer

Powered by FluxBB