How to run a dynamically generated query(text format) in advance sql block?

Am new to outsystems,I want to run a dynamically generated sql(in text format) in advance sql block but am not able to execute the same if i pass the text as parameter(@parameter) and then execute using EXEC @parameter.

did some one face similar issues?
Did you set the expand inline parameter property to true?

Note: Do not forget to use EncodeSql function to prevent SQL injection in the database.

Hi Andre,
Thank You for quick Turn around:).It helped:)
Nithin S C


can you share your dynamic query, am getting error : "'[OSUSR_' found in 'Expand Inline' parameter is a reserved prefix" .

Thanks in Advance.

Hi Deepak,

You should use the OutSystems entity and attribute names in your SQL, rather than the physical table names as some of the system entities are reserved.

Syntax is explained in Write Your Own SQL Queries.



Thanks a lot Tiago...

But am generating the Sql query dynamically and then am executing on SQL. 

How to write the Dynamic Sql qurey on outsystems?

The same as you would write it inside a SQL Node. An Expand Inline parameter is just  a placeholder for string that will be filled in runtime, so the query you write must follow the same convention - {Entity}.[Attribute].