runsqlscript
(To be removed) Run SQL script on database
The runsqlscript
function will be removed in a future release.
Use the executeSQLScript
function instead. For details, see Compatibility Considerations.
Description
returns a results
= runsqlscript(conn
,scriptfile
)cursor
object array that contains a
cursor
object for each executed SQL command in
the SQL script file scriptfile
using the database connection. The
runsqlscript
function executes all SQL commands in the SQL
script file.
specifies additional options using one or more name-value pair arguments. For
example, results
= runsqlscript(___,Name,Value
)'RowInc',5
returns results from the executed SQL
statements in the SQL script file in increments of five rows at a time.
Examples
Input Arguments
Output Arguments
Limitations
Use
runsqlscript
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.runsqlscript
is not designed to handle SQL scripts containing continuous PL/SQL blocks withBEGIN
andEND
, such as stored procedure definitions or trigger definitions. However, table definitions do work.An SQL script containing any of the following can produce unexpected results:
Apostrophes that are not escaped, including the ones 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
runsqlscript
to return an error.
More About
Tips
Any values assigned to
RowInc
orQTimeOut
apply to all queries in the SQL script. For example, if'RowInc'
is set to5
, then all queries in the script return at most five rows in their respective query results.You can set preferences for the query results using the
setdbprefs
function. Preference settings apply to all queries in the SQL script. For example, if the'DataReturnFormat'
is set to numeric, all query results return as numeric matrices.