User`s guide

Generate SQL and MATLAB Code
4-25
Generate SQL and MATLAB Code
In this section...
“Save Queries as SQL Code” on page 4-25
“Generate MATLAB Code” on page 4-26
Use Database Explorer to generate SQL or MATLAB code. Once you define a SQL query
using the SQL Criteria panel, you can generate the SQL code for running a SQL script.
You can also generate MATLAB code to automate connecting to the database, running a
SQL query, and performing data analysis on the imported data.
Save Queries as SQL Code
You can save a Database Explorer query as SQL code.
1
In the Database Browser pane, select data from a single table or multiple tables.
Use the SQL Criteria panel to create queries and display the results in the Data
Preview pane.
2
After you have created a query using the SQL Criteria panel, select Import >
Generate SQL to display the SQL code in the MATLAB Editor.
3
Save the SQL code to a .txt or .sql file. You can then use the SQL statements to
rebuild a query using the SQL Criteria panel. Alternatively, you can use the .sql
file to import data programmatically into MATLAB by using runsqlscript.