Dynamically assign SQL queries to be executed

Linx allows you to dynamically assign input parameters to most components and objects. This also allows for the dynamic assignment of SQL Queries to the ExecuteSQL component.

You can thus assign queries constructed or retrieved from other Linx components - as long as the output of the query is predictable and can be assigned in the result type.

For example, we can retrieve a query from another source or construct it using elements from other components. The screenshot below shows how a column name comes from a string variable. However, this can, for example, come from a file, database or even API call.

Here, we set the SQL of the ExecuteSQL component using the expression editor. We can also assign the query resulting from another component or variable:

One important thing to remember is that if the query results in data that needs to be retrieved, and you want to work with the data downstream in your function, you will need to define a result type. In these instances, it can be very helpful to assign a predictable column name to the columns retrieved. For example, in the first screenshot we defined the column with the alias MyAlias. We can define this column name as the output of our Query in the Result Type: