Encapsulation of table interface

Encapsulation of table interface

  

I really don't like the tight binding of tables with their create, update, delete, etc. functions. I'd like to encapsulate these functions so that I can pass in a table name (including path) and invoke the correct function. My idea is to do this by passing in both the table name and an object containing name/value pairs representing the table column names and values plus key values to query on (if required). 


I imagine forming a SQL query is the way to do this, but I'm having trouble understanding how I can pass the column names and values from the name/value pairs into the SQL query. 


Any ideas about how to do this or can anyone think of a different approach?


Also, another really useful thing would be the ability to cast types from one to another. I don't see any way to do this in outsystems.

Hi Steve

From what I understood, you are trying to pass a list of column names to a SQL node. Unfortunately you can only pass Basic Type parameters, so would have to know in advance how many columns you will be using.

Regarding the type casting, you can assign different type values to variables (ex: assign a number value to a text variable) and the platform implicitly handles the conversion for you. In cases where it is not possible, you have Data Conversion functions available (see attached image)



Hi,

If I understood what you want to do, you will need to use expand inline parameters. Build the SQL concatenating a text variable and pass the value to a expand inline parameter.

Expand inline will define part or all query SQL.

Nelson Inácio wrote:

Hi,

If I understood what you want to do, you will need to use expand inline parameters. Build the SQL concatenating a text variable and pass the value to a expand inline parameter.

Expand inline will define part or all query SQL.


Can you give me an example of using expand inline parameters? 


Steve Sommers wrote:

Nelson Inácio wrote:

Hi,

If I understood what you want to do, you will need to use expand inline parameters. Build the SQL concatenating a text variable and pass the value to a expand inline parameter.

Expand inline will define part or all query SQL.


Can you give me an example of using expand inline parameters? 


On this example I'm using an expand inline parameter to order the query results, to work with List_SortColumn Widget. MainFlow.Contacts screen. That's the most common example of usage of exapand inline parameters.