#1 2019-11-01 17:43:34

sergiogarciaruso
Member
Registered: 2019-06-21
Posts: 5

It's posible to use multiple connections/models in one REST (Oracle)

Hi all. We already have an Oracle database since ten years ago, and until now our Delphi applications are client/server. Now we want to build a REST server using Mormot, but we have a problem.
In Oracle we have four schemas, and each one have its one tables... How can we model that scenario using Mormot?
Maybe creating four connection (aProps[1] := TSQLDBOracleConnectionProperties.Create() ... aProps[4] := TSQLDBOracleConnectionProperties.Create), and eventually four Models for every connection (aModel[1] := CreateModel1 ... aModel[4] := CreateModel1), using VirtualTableExternalRegisterAll() with each pair? What about REST server where only one model we can use (TSQLRestServerDB.Create(model,...)) ?

I appreciate the help you could give us.

Regards,
   Sergio

Offline

#2 2019-11-01 17:51:15

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

Re: It's posible to use multiple connections/models in one REST (Oracle)

The schema is not about the connection, but about the table.
A single TSQLDBOracleConnectionProperties is enough.
And you can customize the schema during external database mapping.

But since your database is old, make sure that it meets the mORMot ORM requirements, mainly an Integer primary key for the tables...

For server-side REST process, your are not forced to use the ORM. Not at all.
What I have used with legacy databases is:
- interface based services to publish the REST process;
- define an interface and a class for an agnostic Persistence service;
- SynDBOracle direct connection access to the database for better performance, and direct JSON/variant result integration;
- reuse existing SQL statements, without the ORM, when it is not compatible (primary key), or too complex;
- use the ORM for new or compatible tables.

Offline

#3 2019-11-01 18:22:31

sergiogarciaruso
Member
Registered: 2019-06-21
Posts: 5

Re: It's posible to use multiple connections/models in one REST (Oracle)

Hi. When you say "external database mapping" what do you mean? The TSQLRecord classes? Can you give us an example of how to map two tables belonging to two different schemes in Oracle? Thank you for your quick response.
Sergio

Offline

#4 2019-11-01 18:27:25

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

Re: It's posible to use multiple connections/models in one REST (Oracle)

Check the doc about external databases.
It is pretty clearly explained.
See e.g. https://synopse.info/files/html/Synopse … l#TITL_146

Offline

Board footer

Powered by FluxBB