1

I am trying to execute a Sql query in matlab. The sql uses 'select' command for selecting a particular row using a columnname which matches a value that is stored in variable given in the following code. When I execute this , I get an error : Error using ==> database.exec Too many input arguments.

q=value;%computed value. 
conn1=database('Dbname','',''); 
fna=exec(conn1,'select * from table1 where ImageName="',q,'"');
fna=fetch(fna); fda=fna.data;

2 Answers 2

1

You are passing four input arguments, the last three ones must be concatitated to one sql command.

sqlquery=['select * from table1 where ImageName="',q,'"'];
fna=exec(conn1,sqlquery);
Sign up to request clarification or add additional context in comments.

1 Comment

:Further i am storing the contents of fda in a cell. When i try to print the contents present in the cell , there is another error : C = fda.'; sprintf('%d%d%d'C{1,1},C{2,1},C{3,1}) Error :Cell contents reference from a non-cell array object.
0

in the matlab manual it says that exec has the following syntax:

curs = exec(conn,sqlquery)
curs = exec(conn,sqlquery,qTimeOut)

You have four parameters in the exec functions, that's what the error means!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.