File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 7777cursor = connection .cursor ()
7878cursor .execute ("delete from TestTempTable where IntCol = 1" )
7979cursor .execute ("insert into TestTempTable values (1, null)" )
80- input (
81- "Please kill %s session now. Press ENTER when complete."
82- % sample_env .get_main_user ()
83- )
80+
81+ try :
82+ sql = """select unique
83+ 'alter system kill session '''||sid||','||serial#||''';'
84+ from v$session_connect_info
85+ where sid = sys_context('USERENV', 'SID')"""
86+ (killsql ,) = connection .cursor ().execute (sql ).fetchone ()
87+ print (f"Execute this SQL statement as a DBA user in SQL*Plus:\n { killsql } " )
88+ except Exception :
89+ print (
90+ "As a DBA user in SQL*Plus, use ALTER SYSTEM KILL SESSION "
91+ f"to terminate the { sample_env .get_main_user ()} session now."
92+ )
93+
94+ input ("Press ENTER when complete." )
95+
8496try :
8597 connection .commit () # this should fail
86- sys .exit ("Session was not killed. Terminating ." )
98+ sys .exit ("Session was not killed. Sample cannot continue ." )
8799except oracledb .DatabaseError as e :
88100 (error_obj ,) = e .args
101+ print ("Session is recoverable:" , error_obj .isrecoverable )
89102 if not error_obj .isrecoverable :
90103 sys .exit ("Session is not recoverable. Terminating." )
91104ltxid = connection .ltxid
You can’t perform that action at this time.
0 commit comments