About EasyMorph Tutorials & Examples Web-help

Reading and executing SQL from a file

Sometimes it might be necessary to read an arbitrary SQL query from a file and execute it. Here is an example that does the following:

  • Read query from a file (specified by a parameter)
  • Send the query to a sub-project
  • The sub-project executes the query and exports the result into a text file (also specified by a parameter)

Unpack the example and run export-data.morph in EasyMorph. When executed successfully it should create a text file named “export.csv” in the project folder.

export-data.zip (241.4 KB)
image

1 Like

Hello, i have a similar problem.
I have a database function that returns a SQL statement.
I would like to execute this via Database-Command.

something like this:

DECLARE @SQLSTATEMENT CHAR(100);
SET @SQLSTATEMENT = execute (GetSQLStatement(‘MySchemaName’, ‘MyTableName’))
execute (@SQLSTATEMENT);

Does that work too?

brest regards,

Adrian

Hi Adrian,

Yes, you can try to use a similar approach.

ok, i got it :grin:

1 Like
To learn more about EasyMorph visit easymorph.com.