First, create a table named tblTest on the SQL server with one field,
named 'test' of type nvarchar(50)
Then run the following on matlab:
DBName = 'YourDBName';
DBServer = 'YourSQLServerName';
conStr = sprintf('jdbc:odbc:Driver={SQL Server};Server=%s;Database=
%s;Trusted_Connection=Yes;Integrated Security=SSPI', DBServer,
DBName);
conn = database('','','','sun.jdbc.odbc.JdbcOdbcDriver',conStr);
fastinsert(conn, 'tblTest', {'test'}, {'one'; ''});
On a 64bit windows machine this will produce the following error:
java.sql.SQLException: SQL Exception : Unknown SQL Type for
PreparedStatement.setObject (SQL Type=-9
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.emulateExecuteBatch
(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeBatchUpdate(Unknown
Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeBatch(Unknown Source)
Oddly enough swaping the entries (last argument of fastinsert) does
not produce an error. So the following works:
fastinsert(conn, 'tblTest', {'test'}, {''; 'one'});
=========
Microsoft changed their ODBC sql header files when they released 64
bit windows so some of the ODBC APIs use a new SQLULEN which is 64
bits where it was 32 bits before. My guess is that this is causing the
problem.
Can anyone reproduce this on a 64bit machine? Vista? Matlab 2009a or
b?
Anyone has a clue for a workaround?
thanks.
/reza