executeSQLScript
Syntax
Description
uses the database connection results
= executeSQLScript(conn
,scriptfile
)conn
to return a structure array that
contains results as a table (by default) for each executed SQL SELECT
statement in the SQL script file. For any non-SELECT
SQL statements, the
corresponding table is empty. The executeSQLScript
function executes
all SQL statements in the SQL script file.
specifies additional options using one or more name-value pair arguments. For example,
results
= executeSQLScript(conn
,scriptfile
,Name,Value
)'DataReturnFormat',"cellarray"
stores the results of an executed SQL
statement as a cell array. The results are stored in the Data
field of
the results
structure array.
Examples
Input Arguments
Output Arguments
Limitations
Use the
executeSQLScript
function to import data into MATLAB®, especially if you have long and complex SQL queries that are difficult to convert into MATLAB character vectors or string scalars. TheexecuteSQLScript
function does not support SQL scripts containing continuous PL/SQL blocks withBEGIN
andEND
, such as stored procedure definitions or trigger definitions. However,executeSQLScript
does support table definitions.An SQL script containing either of the following can produce unexpected results:
Apostrophes that are not escaped, including those in comments. For example, write the character vector
'Here's the code'
as'Here''s the code'
.Nested comments.
An SQL script containing more than 25,000 characters causes the
executeSQLScript
function to return an error.
Version History
Introduced in R2020b