
mysql values not updating
조회 수: 4 (최근 30일)
이전 댓글 표시
I have written a code to update values in matlab as shown below
sqlquery = strcat('update attend set attendence=attendence+1 where id=',int2str(idupdate)); disp(sqlquery); curs = exec(conn,sqlquery); curs=fetch(curs);
It update my value but the updated value is not committed. When I try to commit there is no change.
Tell me if there is anything to change. I am using the native odbc driver to connect.
댓글 수: 0
답변 (1개)
Rajanya
2024년 10월 7일
I understand that you are trying to update values in a table corresponding to a database in MySQL. Given that the connection is established properly with the correct database, one of the reasons for this could be that the ‘AutoCommit’ property of the connection object is set to ‘off’.
I tried with an example table and was able to reproduce the same. After setting the proper connections and setting the ‘AutoCommit’ property manually to ‘on’, the problem was solved and the changes were permanently committed to the database table 'my_test'. The table contains two columns, 'id' and 'name'.
conn = database('database_name', 'user_name', 'password', ...
'Vendor', 'MySQL', 'Server', 'localhost', 'PortNumber', 3306);

You can visit the related documentation pages for ‘commit’ and ‘update’ by the following commands:
doc commit
doc update
Hope this helps!
댓글 수: 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!