フィルターのクリア

I have to count the number of occurrences of a record (x) in a Table "Stocks" from a database "MultiProductInventory"

2 ビュー (過去 30 日間)
I have to count the number of occurrences of a record (x) in a Table "Stocks" from a database "MultiProductInventory". The database table consists of 9 fields , the first field is the PI (Product Id) and the other fields are F1,F2,...,F8. The arguments for field variables Pi,F1,F2,..,F8 are supplied at run time from an array (x). I ran the following code. The MATLAB is giving error message, "Invalid or closed connection" and " Undefined function or method "fetch" for input argumnts of type struct. can any body explain me where is the mistake in the code.
function [ Pocc ] = Multiprodinv1(x)
dbpath = ['C:\ Users\admin\Documents\MultiProductInventory'];
url = [ [ 'jdbc:odbc:Driver = {Microsoft Access Driver(*.mdb,*.accdb)};DSN =' ';DBQ ='] dbpath];
conn = database('MultiProductInventory','','','Sun.jdbc.odbc.JdbcOdbcDriver',url);
query1 = ['select all ID from Stocks where PI=',num2str(x(1))];
query2=[''];
for fidx=1:8
query2 = strcat(query2,sprintf('and F%d=',fidx),num2str(x(fidx+1)));
end
query = strcat(query1,query2);
curs=exec(conn,['query']);
curs.Message
curs=fetch(curs);
y= curs.Data;
Pocc=length(y);
  2 件のコメント
the cyclist
the cyclist 2016 年 8 月 13 日
What is the output of your command
conn = database('MultiProductInventory','','','Sun.jdbc.odbc.JdbcOdbcDriver',url)
Kallam Haranadha Reddy
Kallam Haranadha Reddy 2016 年 8 月 14 日
I got the following message.
JDBC Driver Error: Sun.jdbc.odbc.JdbcOdbcDriver. Driver Not Found/Loaded.

サインインしてコメントする。

採用された回答

the cyclist
the cyclist 2016 年 8 月 14 日
Looks like your database command is not finding the driver. It's difficult to give specific advice on this. I would suggest looking at the following:
  1 件のコメント
Kallam Haranadha Reddy
Kallam Haranadha Reddy 2016 年 8 月 15 日
Thanks. I learned that I have to install JAVA for using JDBC drivers. Any how, without using JDBC, i used ODBC drivers and ran the program. It gave the results.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by