fetch - cursor.fetch or database.fetch

About fetch, cursor.fetch, and database.fetch

There are two fetch functions in this toolbox, cursor.fetch and database.fetch. The fetch function runs one of these functions, depending on what object you provide to it as an argument. Use the syntax fetch with the appropriate object argument rather than explicitly specifying cursor.fetch or database.fetch.

For example, cursor.fetch runs when you pass a cursor object, curs, to fetch as an argument.

conn=database(...)
curs=exec(conn, sqlquery)
fetch(curs)

The database.fetch function runs when you pass a database object, conn, to fetch as an argument.

conn=database(...)
fetch(conn, sqlquery)

In this example, the results are effectively identical. database.fetch runs exec and returns results to the cursor object. It then runs cursor.fetch, returns results, and closes the cursor object. This shows that you can use a single call to the database.fetch function to get the same results as if you had called two functions, exec and cursor.fetch.

cursor.fetch returns a cursor object on which you can run many other functions, such as get and rows. For this reason, cursor.fetch is recommended for use in most situations. To import data into the MATLAB® workspace without meta information about the data, use database.fetch instead of cursor.fetch.

Throughout the documentation, references to fetch denote cursor.fetch unless explicitly stated otherwise.

Explicitly specify database.fetch or cursor.fetch only when running help or doc. To get help for database.fetch, run help database.fetch. Similarly, to view the reference pages for either version of fetch, run doc database.fetch or doc cursor.fetch.

See Also

cursor.fetch, database, database.fetch, exec

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS