Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Loop with sleep ( without any dbms package )

USER101Sep 21 2022

Hello experts ! 

Need your help and advise on a small piece of code. I am in the middle of testing TAC ( Transparent Application Continuity ). In the process, I remotely connect using the service that is configured for TAC and was trying to simulate the planned maintenance by issuing "shutdown immediate" and node crash by aborting the instance ( both using SRVCTL ) but I did not see the connections failover and replay on the surviving instance. On checking with Oracle, they asked me to remove the dbms_lock entry in the code as it's a stateful package and they say replay is not possible with stateful packages.

My question to you is, how can I let a transaction run for around 30 mins, without inserting too many records but at the same time simulate the test cases outlined above.

begin
for i in 1..2000 loop
insert into tbl_x values(i, sysdate);
dbms_lock.sleep(1);
end loop;
end;
/

I call the above code via a shell script below :

$ORACLE_HOME/bin/sqlplus -s "/@${SERVID}_GEN" <<EOF
set heading off
set timing on
set serveroutput on size 999999
whenever SQLERROR EXIT 1

select SYS_CONTEXT ('USERENV', 'INSTANCE') from dual;

set feedback off

spool ${LOG}.lst
set serveroutput on size 999999

select * from global_name;
@/ora02/TAC_TEST.sql
commit;

spool off

Thanks in advance.

This post has been answered by Saubhik on Sep 21 2022
Jump to Answer
Comments
Post Details
Added on Sep 21 2022
10 comments
529 views