Database Toolbox Previous page   Next Page

Using VQB Queries in Database Toolbox Functions

Use the Visual Query Builder to easily create a query with its graphical interface. Then copy information from the SQL statement or MATLAB command field for use with Database Toolbox functions. For more information, see Using Functions in the Database Toolbox.

Example Using VQB SQL Statement with exec Function

In the VQB, select Query -> Load and choose basic.qry, which you created in Saving a Query. The SQL statement in the VQB contains the SQL query.

You can run the same query using Database Toolbox functions in the Command Window.

  1. Connect to the database with the database function. This is the equivalent of selecting the Data source in the VQB.
  2. Issue an SQL query with the exec function. This is the equivalent of selecting the Tables and Fields in the VQB. In creating the exec statement, you can copy the content of the SQL statement from the VQB and paste it into the Command Window.
  3. Get the data using fetch.
  4. View the results.
  1. MATLAB displays

Example Using VQB MATLAB Command with insert Function

In the VQB, select Query -> Load and choose export.qry, which you created in Exporting Data Using the VQB. The MATLAB command in the VQB contains the insert statement.

You can run the same query using Database Toolbox functions in the Command Window.

  1. Connect to the database with the database function. This is the equivalent of selecting the Data source in the VQB.
  2. Create the data to insert. Use
  3. Export the data using the insert function. Copy the contents of the MATLAB command field from the VQB, paste it into the Command Window, change the variable name in the statement from export_data to D, and run the statement. This is the equivalent of assigning the MATLAB workspace variable and executing the query in the VQB.
  1. MATLAB exports the data to the database, which you can verify by viewing the table in Access.


Previous page  Exporting BOOLEAN Data Using Functions in the Database Toolbox Next page

© 1994-2005 The MathWorks, Inc.