Skip to Main Content Skip to Search
Product Documentation

Saving Queries in Files

About Generated Files

Select Query > Generate MATLAB File to create a file that contains the equivalent Database Toolbox functions required to run an existing query that was created in VQB. Edit the file to include MATLAB or related toolbox functions, as needed. To run the query, execute the file.

The following is an example of a file generated by VQB:

% Set preferences with setdbprefs.
s.DataReturnFormat = 'cellarray';
s.ErrorHandling = 'store';
s.NullNumberRead = 'NaN';
s.NullNumberWrite = 'NaN';
s.NullStringRead = 'null';
s.NullStringWrite = 'null';
s.JDBCDataSourceFile = '';
s.UseRegistryForSources = 'yes';
s.TempDirForRegistryOutput = '';
setdbprefs(s)

% Make connection to database. Note that the password has been omitted.
% Using ODBC driver.
conn = database('dbtoolboxdemo','','password');

% Read data from database.
e = exec(conn,'SELECT ALL StockNumber,January,February FROM salesVolume');
e = fetch(e);
close(e)

% Close database connection.
close(conn)

VQB Query Elements in Generated Files

The following VQB query elements do not appear in generated files:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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