Anomalous commit/rollback behavior

조회 수: 1 (최근 30일)
David Goldsmith
David Goldsmith 2011년 8월 8일
Please observe:
K>> get(conn, 'AutoCommit') % AutoCommit is Off
ans =
off
K>> curs = fetch(exec(conn, ['select * from RawValue r inner join CalculatedValue c '... 'on r.RawValueID=c.RawValueID where r.RealTimeFlagsID=-9998 and '... 'not r.SiteID like ''ADM%'''])) % Matlab just added the queried data to the database; note that (a lot of) data is being returned
curs =
Attributes: []
Data: {5271x58 cell}
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: [1x141 char]
Message: []
Type: 'Database Cursor Object'
ResultSet: [1x1 sun.jdbc.odbc.JdbcOdbcResultSet]
Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement]
Fetch: [1x1 com.mathworks.toolbox.database.fetchTheData]
K>> commit(conn) % Now I (ostensibly) commit it
K>> curs = fetch(exec(conn, ['select * from RawValue r inner join CalculatedValue c '... 'on r.RawValueID=c.RawValueID where r.RealTimeFlagsID=-9998 and '... 'not r.SiteID like ''ADM%'''])) % Yup, it's still there! :)
curs =
Attributes: []
Data: {5271x58 cell}
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: [1x141 char]
Message: []
Type: 'Database Cursor Object'
ResultSet: [1x1 sun.jdbc.odbc.JdbcOdbcResultSet]
Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement]
Fetch: [1x1 com.mathworks.toolbox.database.fetchTheData]
K>> rollback(conn) % My understanding is that this should now have no effect
K>> curs = fetch(exec(conn, ['select * from RawValue r inner join CalculatedValue c '... 'on r.RawValueID=c.RawValueID where r.RealTimeFlagsID=-9998 and '... 'not r.SiteID like ''ADM%'''])) *% But wait, there's less! :(*
curs =
Attributes: []
Data: {'No Data'}
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: [1x141 char]
Message: []
Type: 'Database Cursor Object'
ResultSet: [1x1 sun.jdbc.odbc.JdbcOdbcResultSet]
Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement]
Fetch: [1x1 com.mathworks.toolbox.database.fetchTheData]
Can someone please explain this result to me?
Thanks!
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 8월 8일
In the example you're using plain SELECT queries wich do not affect the content of a TABLE.

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

답변 (0개)

카테고리

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