A simple page was created to illustrate how this component works. In the end you should be able to select a specific eSpace and convert a table name from its logical name to the physical name or vice-versa.
To achieve this purpose we will use the SQL Map component, we need to:
Once you complete all items above, you will have a source code similar to our demo module that can be used as a reference to solve any question you could have during the implementation of our demo page.
1. Enable the Component
Install the SQL Map application in your environment. It should provide you with three server actions:
Conv_LogicalToPhysical - Action to convert the logical name of your tables to its physical format.
Conv_PhysicalToLogical - Action to convert the physical name of your tables to its logical format.
GetESpaces - Action that retrieves all the eSpaces available in your environment. It can also only retrieve the selected eSpaces given its name and/or id.
We are building an application on an Outsystems environment that is using SQL Server, so we will manage the dependencies of our application, select the SQLMap module and make sure we have available the Conv_LogicalToPhysical, Conv_PhysicalToLogical and GetESpaces server actions and the OSSYS_eSpace structure.
SQLMap module.
2. Define the logic in our screen
The goal of the component is to convert your table names from logical to physical and the opposite.
This is achieved using the Conv_LogicalToPhysical or Conv_PhysicalToLogical. The component provides one extra action that is optional, as its goal is to retrieve information about the eSpaces.
In our page, we will display all the available eSpaces on our environment so we will use the GetEspaces server action that is now available.
Create a screen, name it SQLMap, and create a data action that runs at the start of the screen and place GetEspaces action inside it. Create a local variable and place it in the ‘name’ input parameter of the actions. This will come useful for us to filter for the desired eSpace.
We created a logic to enable/disable the selected eSpaces. The purpose of this implementation is to understand that if the id of the eSpace is not available, a table that is inside it cannot be converted from logical to physical or the opposite. Please use the demo as a reference to see this implementation on how to retrieve the eSpaces.
Drag and drop two text area widgets to your screen and create two local variables called physical and logical. Associate these variables each to the input widgets. They will store our table names in the respective format and allow us to convert it.
Create two buttons and name them ‘convert to physical’ and ‘convert to logical’. Your screen should look like this:
SQLMap demo screen.
Create a boolean variable on the Demo screen and call it HandleParams, set the default to false. Drag and drop to the screen a checkbox widget and associate it with this variable.
After all this procedure our screen should look similar to this:
SQLMap demo screen part1.
SQLMap demo screen part2.
3. Define the logic to convert from the table’s Logic name to its Physical name.
Our goal is to introduce the logical name of a certain number of tables on the first text area widget and then press the ‘Convert to Physical’ button to have the output showing on the second text area that is below. To do this let's first start by creating a client action and define it as the event of the button ‘Convert to Physical’. Inside this action, drag and drop the Conv_LogicalToPhysical server action that is provided by the component and fill its inputs:
The action will then return:
Our client action in the demo will look like this:
ConvertLogicalToPhysical client action.
4. Define the logic to convert from the table’s Physical name to Logical name.
Our goal now is to do the opposite: insert the physical name on the second text area widget and click on the ‘Convert to Logical’ button, the result should appear on the first text area widget.
Create a client action to deal with this button, inside it place the Conv_PhysicalToLogical server action that is provided by the component and fill its inputs:
ConvertPhysicalToLogical client action.
After publishing, you should now have a demo page that lets the user convert the tables names from their logical into their physical form or vice-versa, when their respective eSpace is selected. In the end your screen in the Service Studio should look like this:
SQLMap screen.