User`s guide
6 Using Database Toolbox Functions
6-48
Importing Data Using the fetch Function
In this section...
“About the fetch Function” on page 6-48
“fetch Workflow” on page 6-48
“Using fetch with a Cursor Object” on page 6-49
“Using fetch with Cursor and Database Connection Objects” on page 6-50
“Database Consideration” on page 6-51
About the fetch Function
Use the fetch function to import data into the MATLAB workspace. Here are general
points about using fetch:
• Use Database Explorer to retrieve data as an alternative to using fetch.
• fetch supports the native ODBC interface.
fetch Workflow
The fetch function runs the appropriate processes to retrieve data depending on what
object you provide to it as an input argument. This function works with cursor objects
and database connection objects for JDBC/ODBC bridge and JDBC interfaces. This
function works with cursor objects only for the native ODBC interface.
For the JDBC database driver, use the database function to establish a database
connection.
conn = database(...)
fetch then runs when you pass a cursor object, curs, to retrieve as an argument.
curs = exec(conn,sqlquery)
curs = fetch(curs)
The fetch function runs when you pass a database object, conn, to retrieve as an
argument.
fetch(conn,sqlquery)