#1 2016-02-24 10:43:49

GLM
Member
Registered: 2014-01-22
Posts: 14

External Oracle DB. Pb with CreateMissingTables

Hello,

I'm trying to use mORMot with a Standard Database having an external Table in a Oracle DB, by this way :

procedure TsrvMainDm.ConnectMainDB;
begin
  TSynLog.Enter(Self, 'ConnectMainDB');
  FOracleProps := TSQLDBOracleConnectionProperties.Create('URIOS', '', 'URIOS_INF', 'VALIDU');
  //FOracleProps := TSQLDBOracleConnectionProperties.Create('//DellTHIBAUT:1526/Urios3', '', 'URIOS_INF', 'VALIDU');

  FMainDataModel := TSQLModel.Create([]);

  FMainDataModel.AddTable(TSQLPlan);
  // Redirection d'une table du modele sur la base Oracle
  VirtualTableExternalRegister(FMainDataModel, TSQLPlan, FOracleProps, 'P_PLAN');
  FMainDataModel.Props[TSQLPlan].ExternalDB.MapField('ID', 'NO_PLAN');

  FMainDB := TSQLRestServerDB.Create(FMainDataModel, 'Main.db3', True);
  FMainDB.CreateMissingTables(0);

end;

This work fine when the Oracle database is on my computer ("URIOS" case).
But when it is on a remote one (on the local network) I lose my application during "FMainDB.CreateMissingTables(0);".

Any Idea why ?

Thank you

Offline

#2 2016-02-24 10:55:17

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

Re: External Oracle DB. Pb with CreateMissingTables

I guess this is because the connection at FOracleProps is not correct.

Try to use SynDBExplorer to test the working connection string.

Offline

#3 2016-02-24 13:22:10

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

Well with the SynDBExplorer, the connection string works fine !

Offline

#4 2016-02-24 13:44:59

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

Re: External Oracle DB. Pb with CreateMissingTables

So what is the exact error in CreateMissingTables, including the stack frame and line numbers?

Offline

#5 2016-02-24 14:39:19

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

Here are some informations I can give you:

The last point before I lose the application running:

procedure TSQLDataBase.GetFieldNames(var Names: TRawUTF8DynArray; const TableName: RawUTF8);
var R: TSQLRequest;
    n: integer;
begin
  if (self=nil) or (fDB=0) then
    exit; // avoid GPF in case of call from a static-only server
  Lock;
  try
    try
*********************************************************************
      R.Prepare(fDB,'PRAGMA table_info('+TableName+');'); // ESQLite3Exception
*********************************************************************
      n := 0;
      repeat
        if R.Step<>SQLITE_ROW then break;
        if n=length(Names) then
          SetLength(Names,n+MAX_SQLFIELDS);
        Names[n] := sqlite3.column_text(R.Request,1); // cid,name,type,notnull,dflt_value,pk
        inc(n);
      until false;
      SetLength(Names,n);
    finally
      R.Close;
    end;
  finally
    UnLock;
  end;
end;


And the stack :

SynSQLite3.TSQLDatabase.GetFieldNames((),'Plan')
mORMotSQLite3.TSQLRestServerDB.CreateMissingTables(0,[])
srvMainDm_.TsrvMainDm.ConnectMainDB
SrvMainFrm_.TForm3.Button5Click($2D830A0)


Hope this can help you

Offline

#6 2016-02-24 14:49:00

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

Re: External Oracle DB. Pb with CreateMissingTables

I guess you may have an existing local Main.db3 SQlite3 file containing a real Plan table.

Offline

#7 2016-02-24 15:02:55

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

I'have tried with the file deleted.
It's the same : I saw the file being generated (Main.db3 and Main.db3-journal), but noting after.

Offline

#8 2016-02-24 15:13:04

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

Re: External Oracle DB. Pb with CreateMissingTables

Did you try

FMainDataModel := TSQLModel.Create([TSQLPlan]);

as it should have been?

Offline

#9 2016-02-24 15:22:01

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

Yes, I used to.

I'have tried :
  FMainDataModel := TSQLModel.Create([TSQLPlan]);

and
  FMainDataModel := TSQLModel.Create([]); 
  FMainDataModel.AddTable(TSQLPlan);

Offline

#10 2016-02-24 16:15:53

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

Re: External Oracle DB. Pb with CreateMissingTables

I'm not able to reproduce your problem here.

Offline

#11 2016-02-24 16:21:11

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

And something like Firewall ?

But why did I succed with SynDbExplorer ?

I'm going to try on an other computer.

Offline

#12 2016-02-24 16:40:06

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

Well,

I'have tried on an other computer (no firewall) and it's the same result...

Something strange :

  FOracleProps := TSQLDBOracleConnectionProperties.Create('//Delldev5:1526/Urios', '', 'URIOS_INF', 'VALIDU');
  lSQLDBConnection := FOracleProps.NewConnection;
  lSQLDBConnection.Connect
  if not lSQLDBConnection.Connected then
    raise Exception.Create('Message d''erreur');

-> the connection is Ok

Offline

#13 2016-02-24 21:44:29

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

Re: External Oracle DB. Pb with CreateMissingTables

Did you recompile SynDBExplorer with the same source (there may be a regression)?

Please enable the logs, create a .map file at compilation in project options, and send more information.

Offline

#14 2016-02-26 11:16:01

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

Hello AB,

I work a bit on my trouble, and it seems that I've identified somethings :

- my trouble is function of the structure of the external table I try to lock.

If I use a typical table, with an standard ID Field, and another such as VAL1, it work fine (retrieve records and update them)

In fact most of our tables don't have such ID field's name, but often NOID or NO_PLAN.
And the lock I have depends if I try to map a field or not.

Can this help you ?

Offline

#15 2016-02-26 19:19:20

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

Re: External Oracle DB. Pb with CreateMissingTables

I guess the database was not created the same.
Perhaps the table in the local database has been created by the ORM, whereas the external table was already existing.
And there is an issue in the external database column mapping...

Offline

#16 2016-03-01 07:36:01

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

The 2 databases are the same (come from an client's export).

Perhaps it is something like the rigths between the 2 computers.
I'm stil invastigating this problem and working on other fonctions of your framework.
So I'll be back to you as I've some news.

Offline

#17 2016-03-01 09:00:52

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

Re: External Oracle DB. Pb with CreateMissingTables

Sorry for not being able to help any further...

Offline

#18 2016-03-01 15:48:48

GLM
Member
Registered: 2014-01-22
Posts: 14

Re: External Oracle DB. Pb with CreateMissingTables

It doesn't matter.

Regards

Offline

Board footer

Powered by FluxBB