Database Connectivity in MATLAB 2010B picks up only one row from Oracle
显示 更早的评论
There are two problems I'm experiencing with the Database Toolbox:
I'm using the 11g client on Win 7 64 bit.
1.) When it does work, it only pulls one row. 2.) It only works once each time MATLAB is opened.
clear all
% create a database connection object
conn = database('mydb','user','pass')
pingconn = ping(conn)
% define a query
disp('Executing query...') tic; sqlQuery = 'SELECT ALL * FROM MY_TABLE';
%setdbprefs('DataReturnFormat','structure')
setdbprefs('DataReturnFormat','cellarray')
curs = exec(conn, sqlQuery)
fetch = (conn, sqlQuery)
toc;
disp('Completed.')
The strange thing is that is communicates with the database and the query times match up with Oracle PLSQL developer exactly, but after the first run with MATLAB open, MATLAB will not store any variables. Also, it only stroes one row when it does work. I've tried many modifications of the same code with no solutions. This is using ODBC connectivity and the connection was tested successfully.
采纳的回答
更多回答(1 个)
Walter Roberson
2011-3-14
The line
fetch = (conn, sqlQuery)
has no syntactic meaning.
With regard to it only working once: do you perhaps need to do something to "close" the connection after use?
4 个评论
Dude
2011-3-14
Walter Roberson
2011-3-14
fetch = (conn, 'SELECT * FROM MY_TABLE')
has no meaning. () around an expression is used only for prioritization of the expression, but a database object followed by a comma followed by a string is not a valid expression.
>> ('hello','there')
??? ('hello','there')
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
>> (3,5)
??? (3,5)
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
Oleg Komarov
2011-3-14
shouldn't it be: out = fetch(conn, sqlQuery)
Dude
2011-3-15
类别
在 帮助中心 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!