MATLAB: Does fetch command for sql query fail but runsqlscript work

cursordatabaseDatabase Toolboxfetchpostgresqlrunsqlscriptsql

I am connecting to a PostgresQL compliant database and am unable to use the fetch command. It returns a "Invalid fetch cursor". However, if I run the same query using runsqlscript with a *.sql file, it works.
conn=database('dbname','user','pwd','postgresql-9.4.1207','jdbc:address');
resultsFail=fetch(conn,sqlquery); # Returns 'Invalid fetch cursor'
resultsGood=runsqlscript(conn,'test.sql');
# Returns
date
------------
2016-01-14

Best Answer

The answer is that there is a bug in MATLAB 2015b. In order to get this to work use set(conn, 'AutoCommit', 'off').