how can i write delete query in matlab

Respuestas (2)

Oleg Komarov
Oleg Komarov el 2 de Jul. de 2011
EDIT
Use:
curs = exec(conn,'delete query')
where delete query is one of the expression as indicated here http://www.w3schools.com/sql/sql_delete.asp
check if you queried correctly with:
curs.message

4 comentarios

sayer ali
sayer ali el 2 de Jul. de 2011
i try this
exec(conn,'DELETE FROM schduale')
exec(conn,'DELETE * FROM schduale')
but dos not work
Oleg Komarov
Oleg Komarov el 2 de Jul. de 2011
What do you mean does not work, error message, unexpected result?
Oleg Komarov
Oleg Komarov el 2 de Jul. de 2011
There's no delete all, unless all is a column
David Goldsmith
David Goldsmith el 4 de Mayo de 2012
I too was finding that this didn't work, and worse: it was "hard-locking" the DB such that I had to exit MATLAB in order to be able to access the DB again, even from w/in MATLAB! However, that was the clue, having remembered similar problems in the past, that eventually led me to the solution: chances are, sayer, (and anyone else who finds this 'cause you're having the same problem) that your DB has autocommit turned off (as it should be), so DB change operations (as opposed to merely query operations) needed to be committed before they "take," i.e., after your exec(conn, 'DELETE FROM table WHERE ...'), you must run commit(conn). So, for careful execution, I recommend code something like this:
curs = exec(conn, deleteStatement);
if isempty(curs.Message)
commit(conn)
:
else
rollback(conn)
:
end
close(curs)
Note that after any DB change operation (i.e., including update and fast/insert) you must call either commit or rollback to remove MATLAB's lock on the DB.
HTH,
DG

Iniciar sesión para comentar.

sayer ali
sayer ali el 2 de Jul. de 2011

0 votos

exec(conn,'DELETE all FROM schduale')

Categorías

Más información sobre Simulink Report Generator en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 2 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by