Created
March 6, 2023 08:08
-
-
Save ilmarkerm/3a0f36a3092cbaf35f60cc7bedce5f7d to your computer and use it in GitHub Desktop.
Execute dynamic SQL in multiple PDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
c integer; | |
r integer; | |
begin | |
for rec in (select distinct con_name from v$active_services where con_id > 2 and lower(name) != lower(con_name)) loop | |
c:= dbms_sql.open_cursor(security_level=>1); | |
dbms_sql.parse(c=>c, | |
statement=>'begin for rec in (select name from v$active_services where lower(name) != lower(con_name)) loop dbms_service.stop_service(service_name=>rec.name, stop_option=>''TRANSACTIONAL'', drain_timeout=>1); end loop; end;', | |
language_flag=>dbms_sql.native, | |
container=>rec.con_name); | |
r:= dbms_sql.execute(c); | |
dbms_sql.close_cursor(c); | |
end loop; | |
end; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment