?? updatableresultset.out
字號:
This is because, after deleteRow, we position the ResultSet before the next row. We don't make a hole for the deleted row and then stay on that deleted holeownDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? falseothersDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? truedeletesAreDetected(ResultSet.TYPE_FORWARD_ONLY)? falseThe JDBC program should look at rowDeleted only if deletesAreDetected returns trueSince Derby returns false for detlesAreDetected for FORWARD_ONLY updatable resultset,the program should not rely on rs.rowDeleted() for FORWARD_ONLY updatable resultsetsHave this call to rs.rowDeleted() just to make sure the method does always return false? falseHave this call to rs.rowDeleted() just to make sure the method does always return false? falsePositive Test6b - For Forward Only resultsets, DatabaseMetaData will return false for ownUpdatesAreVisible and updatesAreDetectedThis is because, after updateRow, we position the ResultSet before the next rowownUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? falseothersUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? trueupdatesAreDetected(ResultSet.TYPE_FORWARD_ONLY)? falseThe JDBC program should look at rowUpdated only if updatesAreDetected returns trueSince Derby returns false for updatesAreDetected for FORWARD_ONLY updatable resultset,the program should not rely on rs.rowUpdated() for FORWARD_ONLY updatable resultsetsHave this call to rs.rowUpdated() just to make sure the method does always return false? falseHave this call to rs.rowUpdated() just to make sure the method does always return false? falsePositive Test7a - delete using updatable resultset api from a temporary tablefollowing rows in temp table before deleteRow C21,C22 --- --- {21,1} {22,1}As expected, no rows in temp table after deleteRow C21,C22 --- ---Positive Test7b - update using updatable resultset api from a temporary tablefollowing rows in temp table before deleteRow C31,C32 --- --- {21,1} {22,1}As expected, updated rows in temp table after updateRow C31,C32 --- --- {123,1} {123,1}Positive Test8a - change the name of the statement when the resultset is open and see if deleteRow still worksThis test works in embedded mode since Derby can handle the change in the name of the statement with an open resultsetBut it fails under Network Server mode because JCC and Derby Net Client do not allow statement name change when there an open resultset against itchange the cursor name(case sensitive name) with setCursorName and then try to deleteRowchange the cursor name one more time with setCursorName and then try to deleteRowPASS!!! passed in embedded modePositive Test8b - change the name of the statement when the resultset is open and see if updateRow still worksThis test works in embedded mode since Derby can handle the change in the name of the statement with an open resultsetBut it fails under Network Server mode because JCC and Derby Net Client do not allow statement name change when there an open resultset against itchange the cursor name one more time with setCursorName and then try to updateRowchange the cursor name(case sensitive name) with setCursorName and then try to updateRowPASS!!! passed in embedded modePositive Test9a - using correlation name for the table in the select sql works in embedded mode and Network Server using Derby Net Client driverCorrelation name for table does not work in Network Server mode (using JCC) because the drivers construct the delete sql with the correlation name rather than the base table namecolumn 1 on this row is 1now try to deleteRowPASS!!! passed in embedded modePositive Test9b - using correlation name for updatable columns is not allowed.Table t1 has following rows C1,C2 -- -- {1,aa } {2,bb } {3,cc }attempt to get an updatable resultset using correlation name for an updatable columnThe sql is SELECT c1 as col1, c2 as col2 FROM t1 abcde FOR UPDATE of c1SQL State : 42X42Got expected exception Correlation name not allowed for column 'C1' because it is part of the FOR UPDATE list.attempt to get an updatable resultset using correlation name for an readonly column. It should workThe sql is SELECT c1, c2 as col2 FROM t1 abcde FOR UPDATE of c1Table t1 after updateRow has following rows C1,C2 -- -- {11,aa } {2,bb } {3,cc }Positive Test9c - try to updateXXX on a readonly column. Should get errorSQL State : 42X31Got expected exception Column 'C2' is not in the FOR UPDATE list of cursor 'SQLCUR15'.attempt to get an updatable resultset using correlation name for an readonly column. It should workThe sql is SELECT c1, c2 as col2 FROM t1 abcde FOR UPDATE of c1Table t1 after updateRow has following rows C1,C2 -- -- {11,aa } {2,bb } {3,cc }Positive Test9d - try to updateXXX on a readonly column with correlation name. Should get errorSQL State : 42X31Got expected exception Column 'COL2' is not in the FOR UPDATE list of cursor 'SQLCUR17'.Table t1 has following rows C1,C2 -- -- {1,aa } {2,bb } {3,cc }Positive Test10 - 2 updatable resultsets going against the same table, will they conflict?delete using first resultsetattempt to send deleteRow on the same row through a different resultset should throw an exceptionSQL State : XCL08Got expected exception Cursor 'SQLCUR19' is not on a row.Move to next row in the 2nd resultset and then delete using the second resultsetPositive Test11 - setting the fetch size to > 1 will be ignored by updatable resultset. Same as updatable cursorsNotice the Fetch Size in run time statistics output.1 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Statement Name: nullStatement Text: SELECT * FROM t1 FOR UPDATE of c1Parse Time: 0Bind Time: 0Optimize Time: 0Generate Time: 0Compile Time: 0Execute Time: 0Begin Compilation Timestamp : nullEnd Compilation Timestamp : nullBegin Execution Timestamp : nullEnd Execution Timestamp : nullStatement Execution Plan Text: Table Scan ResultSet for T1 at read committed isolation level using exclusive row locking chosen by the optimizerNumber of opens = 1Rows seen = 0Rows filtered = 0Fetch Size = 1 constructor time (milliseconds) = 0 open time (milliseconds) = 0 next time (milliseconds) = 0 close time (milliseconds) = 0scan information: Bit set of columns fetched=All Number of columns fetched=2 Number of pages visited=0 Number of rows qualified=0 Number of rows visited=0 Scan type=heap start position: null stop position: null qualifiers:Nonestatement's fetch size is 200Positive Test12a - make sure delete trigger gets fired when deleteRow is issuedVerify that before delete trigger got fired, row count is 0 in deleteTriggerInsertIntoThisTable 1 - {0}column 1 on this row is 1now try to delete row and make sure that trigger got firedVerify that delete trigger got fired by verifying the row count to be 1 in deleteTriggerInsertIntoThisTable 1 - {1}Positive Test12b - make sure update trigger gets fired when updateRow is issuedVerify that before update trigger got fired, row count is 0 in updateTriggerInsertIntoThisTable 1 - {0}column 1 on this row is 1now try to update row and make sure that trigger got firedVerify that update trigger got fired by verifying the row count to be 1 in updateTriggerInsertIntoThisTable 1 - {1}Positive Test13a - Another test case for delete triggercolumn 1 on this row is 1this delete row will fire the delete trigger which will delete all the rows from the table and from the resultsetSQL State : 24000Got expected exception Invalid cursor state - no current row.Verify that delete trigger got fired by verifying the row count to be 0 in table1WithTriggers 1 - {0}Positive Test13b - Another test case for update triggerLook at the current contents of table2WithTriggers C1,C2 -- -- {1,1} {2,2} {3,3} {4,4}column 1 on this row is 2this update row will fire the update trigger which will update all the rows in the table to have c1=1 and hence no more rows will qualify for the resultsetSQL State : 24000Got expected exception Invalid cursor state - no current row.Verify that update trigger got fired by verifying that all column c1s have value 1 in table2WithTriggers C1,C2 -- -- {1,1} {1,2} {1,3} {1,4}Positive Test14a - make sure self referential delete cascade works when deleteRow is issued C1,C2 -- -- {e1,null} {e2,e1} {e3,e2} {e4,e3}column 1 on this row is e1this delete row will cause the delete cascade constraint to delete all the rows from the table and from the resultsetSQL State : 24000Got expected exception Invalid cursor state - no current row.Verify that delete trigger got fired by verifying the row count to be 0 in selfReferencingT1 1 - {0}Positive Test14b - make sure self referential update restrict works when updateRow is issued C1,C2 -- -- {e1,null} {e2,e1} {e3,e2} {e4,e3}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -