File Exchange

image thumbnail

CSE SQL Database Library

version 1.0.0.0 (10.7 KB) by Laurent Cavin
A simple library for dealing with SQL databases.

1 Download

Updated 06 Jan 2004

View License

Editor's Note: EDITOR'S NOTE: Functionality for data exchange between MATLAB and ODBC/JDBC compliant databases is also provided with the MATLAB Database Toolbox.

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 (http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1529&objectType=file).

Cite As

Laurent Cavin (2021). CSE SQL Database Library (https://www.mathworks.com/matlabcentral/fileexchange/4045-cse-sql-database-library), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

jessica zhang

nana sukira

good

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!
Thanks,
Laurent

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.

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.

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.

Torito Stevens

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

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: makeinstall

Inspired: generateXML

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!