Database Connectivity in MATLAB 2010B picks up only one row from Oracle

조회 수: 1 (최근 30일)
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.

채택된 답변

Martijn
Martijn 2011년 3월 14일
Please consider using JDBC drivers instead of ODBC:
  1. They are more reliable on 64-bit Windows.
  2. They should perform better than the ODBC drivers.
  댓글 수: 2
Dude
Dude 2011년 3월 15일
This worked.
You must include the ocijdbc11.dll in the Java path for MATLAB.
Check the output of:
>> java.lang.System.getProperty('java.library.path')
and put the ocijdbc11.dll in there.
Tristan Stöber
Tristan Stöber 2013년 1월 1일
Where do I get 'ocijdbc11.dll' from?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
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
Oleg Komarov
Oleg Komarov 2011년 3월 14일
shouldn't it be: out = fetch(conn, sqlQuery)
Dude
Dude 2011년 3월 15일
Yes Oleg that is correct. I typed that line in manually in the forum and didn't double check myself. That's why it didn't throw errors in the code.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by