sql-map
Reactive icon

SQL Map

icon_trusted
Stable version 2.0.1 (Compatible with OutSystems 11)
Other versions available for 10 and Older
Uploaded
 on 06 December 2021
 by 
4.8
 (20 ratings)
sql-map

SQL Map

Documentation
2.0.1

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:

  • Enable the component
  • Define the logic in our screen
  • Define the logic to convert from the table’s Logic name to its Physical name.
  • Define the logic to convert from the table’s Physical name to Logical name.  


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:

  • Logical - This is the text that should contain the table names to be converted. In our case, associate this input with the local variable that is associated with the text area of the logical name of the tables.
  • ESpacesId - In this input place the id of the eSpaces containing the tables that we wish to convert. Note that if the eSpace does not contain the tables, the conversion will not happen. If multiple Ids are to be passed, separate them by commas.
  • AddDeclarations - If set to true, in the converted text there will be a section disclaiming the inputs (Ex: @name).


The action will then return:

  • Physical - The resulting conversion with our table's physical name.
  • WarningMsg - Warnings that can result from the conversion (for example, when we select multiple eSpaces that have tables with the same name).
  • MultipleMatches - Boolean that will return true if multiple eSpaces were passed in the EspacesId input and they have tables with the same name.


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:

  • Physical - This is the text that should contain the table names to be converted. In our case, associate this input with the local variable that is associated with the text area of the physical name of the tables.
  • ESpacesId - In this input place the id of the eSpaces containing the tables that we wish to convert. Note that if the eSpace does not contain the tables, the conversion will not happen. If multiple ids are to be passed, separate them by commas.
  • RemoveDeclarations - If the content passed on the Physical input parameter described above contains declarations, set this variable to true to remove them.


The action will then return:

  • Logical - The result of the conversion. This output will have a string with all the table names in the logical format.


Our client action in the demo will look like this:

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.