Customers that use Outsystems on top of existing external database(-application)s have the need for customisation of the way they connect to these databases. I have seen changes on the database connection for: change of machine/database, change of schema, connecting with a user other than the default user and connecting with a proxy-connection. I have also seen implementations for other initialisation actions in the external database like actions for context-, audit- or debugging-information.
Please don’t start any discussion on the need for these solutions. This is not a discussion but a fact for some customers.
It would be nice if these customers have a proper way to implement their specific needs.
The current implementation of set database connection (and sometimes even more initialisation-code) before every database-action in Service-actions, Soap- & Rest-api's, OnBeginWebRequest & Fetch data from other sources creates a lot of duplicate code.
And any of these actions can easily be forgotten.
These solutions are sensitive to errors.
Since the introduction of mobile and reactive within Outsystems the need for a proper solution is getting more urgent.
I would suggest a similar solution on the usage of database connections as is implemented on consuming Rest-api's: OnRequest- and OnResponse-actions.
In the OnRequest the connection can be defined and any further initialisation actions like context-, audit- or debugging-information can be done if necessary. If needed, in the OnRepsonse code closing actions like clear the context and audit-/debugging information can be done.
These actions must take place on every begin and end of the session to the defined database connection.
I think the best place to define these actions is where the database connection is defined and maintained: ServiceCenter.
The code to be executed can be written as a public action in a module. The module.action to be executed can be selected when OnRequest and/or OnResponse on the database connection is switched on. There is no need to do any coding from within ServiceCenter; coding is done at the place coding is to be done in ServiceStudio.
Setting the actions on the connection can never be forgotten.
The code will only be created once and in one place.
Best of all: it will work for traditional, reactive, and mobile and will make the move to reactive simpler.
As a consultant I have been allocated to different companies and most of these companies use Outsystems on top of an external database. All these companies will benefit from this solution for the challenge they have in integrating the existing database(-application)s and the challenge of migrating to responsive.