- '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
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Piyush Kumar
am 27 Sep. 2024
Bearbeitet: Piyush Kumar
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!