- 'select * from table1 where ImageName="' is one part of the string.
- q is another part, which is the variable holding your value.
- '"' is the final part of the string.
Error: Too many input arguments while executing a database query
2 ビュー (過去 30 日間)
古いコメントを表示
Hi i am trying to execute a Sql query in matlab. The sql uses select command for selecting a particular row using a columname which matches a value that is stored in variable like the following: q=value;%computed value. conn1=database('Dbname','',''); fna=exec(conn1,'select * from table1 where ImageName="',q,'"'); fna=fetch(fna); fda=fna.data;
When i execute this , i get an error : Error using ==> database.exec Too many input arguments.
0 件のコメント
回答 (1 件)
Piyush Kumar
2024 年 9 月 27 日
編集済み: Piyush Kumar
2024 年 9 月 27 日
The error you are getting is because of the way you’re trying to construct the SQL query string.
fna=exec(conn1,'select * from table1 where ImageName="',q,'"');
This statement is not correct because it splits the query into multiple parts, which causes the "Too many input arguments" error.
You need to combine these parts into a single string before passing it to the exec function.
q = value; % computed value
conn1 = database('Dbname', '', '');
query = sprintf('select * from table1 where ImageName="%s"', q);
fna = exec(conn1, query);
fna = fetch(fna);
fda = fna.Data;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!