?? updatableresultset.out
字號(hào):
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 deleteRowSQL State : nullGot expected exception Invalid operation: setCursorName() called when there are open ResultSet's on the Statement.Positive 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 updateRowSQL State : nullGot expected exception Invalid operation: setCursorName() called when there are open ResultSet's on the Statement.Positive 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 : nullGot expected exception Column not updatableattempt 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 : nullGot expected exception Column not updatableTable 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 '<xxx-cursor-name-xxx>' 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: <xxx-cursor-name-xxx>Statement 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 : nullGot expected exception Invalid operation: result set closedVerify 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 : nullGot expected exception Invalid operation: result set closedVerify 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 : nullGot expected exception Invalid operation: result set closedVerify 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}column 1 on this row is e1update row should fail because cascade constraint is update restrictSQL State : 23503Got expected exception UPDATE on table 'SELFREFERENCINGT2' caused a violation of foreign key constraint 'MANAGES2' for key (e1). The statement has been rolled back.Positive Test15 - With autocommit off, attempt to drop a table when there is an open updatable resultset on itOpened an updatable resultset. Now trying to drop that table through another StatementSQL State : X0X95Got expected exception Operation 'DROP TABLE' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.Since autocommit is off, the drop table exception will NOT result in a runtime rollback and hence updatable resultset object is still openPositive Test16a - Do deleteRow within a transaction and then rollback the transactionVerify that before delete trigger got fired, row count is 0 in deleteTriggerInsertIntoThisTable 1 - {0}Verify that before deleteRow, row count is 4 in table0WithTriggers 1 - {4}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}Verify that deleteRow in transaction, row count is 3 in table0WithTriggers 1 - {3}Verify that after rollback, row count is back to 0 in deleteTriggerInsertIntoThisTable 1 - {0}Verify that after rollback, row count is back to 4 in table0WithTriggers 1 - {4}Positive Test16b - Do updateRow within a transaction and then rollback the transactionVerify that before update trigger got fired, row count is 0 in updateTriggerInsertIntoThisTable 1 - {0}Look at the data in table0WithTriggers before trigger gets fired C1,C2 -- -- {1,1} {2,2} {3,3} {4,4}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 -
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -