View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
CSE SQL Database Library

4.4 | 5 ratings Rate this file 4 Downloads (last 30 days) File Size: 10.7 KB File ID: #4045 Version: 1.0

CSE SQL Database Library


Laurent Cavin (view profile)


08 Oct 2003 (Updated )

A simple library for dealing with SQL databases.

Editor's Notes:

Functionality for data exchange between MATLAB and ODBC/JDBC compliant databases is also provided with the MATLAB Database Toolbox.

| Watch this File

File Information

This library has been implemented because the database toolbox of MathWorks requires to have databases registered in the "ODBC Data Sources" dialog, which is cumbersome when a MATLAB program needs to access different, ever changing databases that for instance result from third party software like AspenTech's BatchPlus, or needs to create new databases and of course write/modify them.

The library contains many functions, which connect to databases, read tables and table definitions, can execute any SQL command and create temporary query tables; the provided help gives details about the different m-files. It has been created for a specific purpose and hence does not support for instance creating or modifying Tables - except via DBExecute that can run any user-defined SQL string.

It supports an error-trapping and (removable) custom warnings.

(c) CSE - L.Cavin, 2003
Version 1.0 - 20.09.2003
This library is free to use and modify for non-commercial purposes.

The file to download is an installer file made with MakeInstall (


Makeinstall inspired this file.

This file inspired Generate Xml.

MATLAB release MATLAB 6.5 (R13)
Other requirements CSE SQL Database Library uses Microsoft Access ActiveX components and therefore must run on a PC where Office is installed. NO SUPPORT FOR UNIX!
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
03 Jul 2008 jessica zhang

19 Jun 2007 nana sukira


Comment only
17 Nov 2005 Laurent Cavin

Thank you all for your reviews. It seems that there are a couple of easy improvements. I do however not have Matlab in my current working place, so I will need some time to post an improved version using your comments.
In between I pray all users to implement themselves the modification proposed in the reviews!

Comment only
16 Nov 2005 Robert Flight

Works great, but a couple of problems.

Getting the number of records does not work properly.
Change line 2 of DBTableDef.m to:

tmp_DataTable = tmp_data.GetRows(32000)';

And to suppress a warning message when there are no records matching a query I inserted the following into DBQuery.m (after line 27):

isnorec = regexpi(blop,'No current record');
if sum(isnorec) == 0
warning('CSE:DBLibrary', ['CSE DB Library Error\nUnable to execute and read query:\n%s'], blop);
end %if

Other than that I think it works like a charm. Nice not to have to buy another toolbox to work with databases.

11 Aug 2005 Ryan C

Very well designed toolbox and easy to use. To use with Matlab 7, change the phrase "COM.access.application" to "COM.Access_Application" in the function DBOpen.m. Then recompile the psuedo code using "pcode *.m" in the SQL DB directory.

09 Jun 2004 Gerald Dalley

If you change line 35 of DBQuery.m to the following:

"DataTable(i, j) = double(tmp_DataTable{i, j});"

(remove the quotes), then it works much better. Without this change, if the first column's datatype determines the datatype of the DataTable array. Often, the first column is an ID column that is an integer, so this kills any floating point fields.

17 Feb 2004 Torito Stevens

The function does what it promises :-)
And without needing to register the data source.

Contact us