필터 지우기
필터 지우기

hi, i have a problem now and i think many people like me! please help, i tried to solve it but i can't

조회 수: 2 (최근 30일)
i have a code below:
...
i = curs.Data{1}
update(connA, 'inputtb', {'Timeout'}, {'out'}, 'where ID = i')
...
in my project, ''i'' isn't constant. Because every time I find ID in my database, it return a new curs.Data{1} so I want ''i'' were a variable. Any time it return curs.Data{1}, the code update (below) will be execute, and ''i'' was imported value from curs.Data{1}. The problem is in whereclause, it seem like we can't put one variable into place ''i'' above!

답변 (2개)

Image Analyst
Image Analyst 2013년 5월 1일
Try making it a string with the number embedded with sprintf():
theQuery = sprintf('where ID = %d', i);
curs.Data{1} update(connA, 'inputtb', {'Timeout'}, {'out'}, theQuery)
By the way, having many people "like" you is not a problem - it's great. You have many friends. Better than have many people hate you. :-)

hoang
hoang 2013년 5월 2일
I mean many people has the same problem like me.(my english is bad ^^)
thank for suggestion, i tried but it doesn't work.
I want to update my datable table in MS ACCESS with a specific row was a variable, not constant. I had defined the ODBC data resource with Matlab database toolbox.
example, in image below, i want to update row ID 5, Timeout from ''in'' to ''out'' but not use the code: update(connA, 'inputtb', {'Timeout'}, {'out'}, where ID = 5')
  댓글 수: 4
Image Analyst
Image Analyst 2013년 5월 3일
I'm not sure what you're asking. What's your code for using the update() function? Actually I haven't used MATLAB with databases, so I'm not going to be any help.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by