Database Toolbox Previous page   Next Page

Saving a Query

After building a query in the VQB, you can save it for later use. To save a query:

  1. Select Save from the Query menu.
  1. The Save SQL Statement dialog box appears.

  1. Complete the File name field and click Save. For the example you ran in Building and Executing a Query, save the query using basic as the filename. Do not include spaces in the filename.
  1. The query is saved with a .qry extension.

For a Select query (retrieves data), the MATLAB workspace variable name you assigned for the query results and the query preferences are not saved as part of the query. This protects you from inadvertently overwriting an existing variable in the MATLAB workspace when you run a saved query. For an Insert query (exports data), the MATLAB workspace variable name whose data you exported is saved as part of the query, although preferences are not saved.

Using a Saved Query

To use a saved query:

  1. Select Load from the Query menu.
  1. The Load SQL Statement dialog box appears.

  1. Select the name of the query you want to load and click Open. For the example, select basic.qry.
  1. The VQB fields reflect the values for the saved query.

  1. To run a Select query (imports data), assign a variable in the MATLAB workspace variable field and click Execute.
  1. For an Insert query (exports data), the saved query might have included a workspace variable, which is shown as part of the MATLAB command field. Type that variable name or type a new name in the MATLAB workspace variable field. Press Return or Enter to see the updated MATLAB command. Click Execute to run the query.


Previous page  Saving, Editing, Clearing Variables for, and Specifying Preferences for Queries Editing a Query Next page

© 1994-2005 The MathWorks, Inc.