About EasyMorph Tutorials & Examples Web-help

Specifying parameter in SQL-query file


I have a bunch of SQL-files over which I iterate, import the data from the database and export to DSET.

In those queries I had to apply the same where clause over and over again. Is there a way to set a parameter in the SQL-file that refers to a parameter in easyMorph where the “where clause” is defined so that I can change it on one place only ?

I know it is possible with direct input of the SQL in EasyMorph but that is not what I want because I have more than 30 queries to run.


Hi Nikolaas,

Parameters are not supported in SQL queries which are read from files.

But you can try to achieve the required behavior like this:

  1. Iterate over SQL files.
  2. Import SQL file as a text with “Import delimited text” action and the following options:
    • “Separator” set to “No separator”.
    • “Columns don’t have headers” checked.
    • “Ignore quoting” in advanced option checked.
  3. Use “Aggregate” action in “Concatenate” mode to concatenate all the lines of an SQL query to a single cell.
  4. Use “Table-wide replace” action to replace some predefined string with a required WHERE clause.
  5. Use “Iterate” action to pass resulting SQL query as a parameter to a subproject.
  6. In that subproject use “Import from database” action in the “Custom SQL” mode with “Custom SQL query” field set to the parameter which contains an SQL query.