- '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
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Piyush Kumar
le 27 Sep 2024
Modifié(e) : Piyush Kumar
le 27 Sep 2024
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 commentaires
Voir également
Catégories
En savoir plus sur Database Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!