MATLAB: Does FETCH function of the Database Toolbox error out in an application generated by the MATLAB Compiler 4.4 (R2006a)

compileDatabase Toolboxdctworker

I have a compiled application that uses the FETCH command from the Database Toolbox to import data from an existing database using ODBC drivers.
This application runs successfully on the development machine. I deploy the application on a target machine that does not have a MATLAB installation. I ensure that the MATLAB Compiler Runtime (MCR) is listed in the PATH environment.
On executing the application, I get the following error:
undefined command/function 'fetch'

Best Answer

The error is caused by an improper installation of the ODBC drivers on the deployment machine. This results in the FETCH command not being able to import data from the database.
To workaround this issue, check to see if the ODBC drivers are setup correctly.
To verify this using MATLAB on the deployment machine, see the example code below:
conn = database('sampledatabase','username','password')
if (~isconnection(conn))
str=conn.Message
h=errordlg(str,'Error','modal' );
while ishandle(h)
pause(.25)
end
error(str)
end