Running Commands in Different Schemas and Pluggable Databases
This article explains how to run commands in a different schema using the DBMS_SCHEDULER and DBMS_SQL packages.
oracle miscconfigurationintermediate
by OracleDba
12 views
This article explains how to run commands in a different schema using the DBMS_SCHEDULER and DBMS_SQL packages.
123456789101112131415
DECLARE
l_user VARCHAR2(30) := 'SCOTT';
l_db_link VARCHAR2(30) := 'my_link';
BEGIN
DBMS_SCHEDULER.create_job(
job_name => l_user || '.' || DBMS_SCHEDULER.generate_job_name,
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN
EXECUTE IMMEDIATE ''DROP DATABASE LINK ' || l_db_link || ''';
END;',
enabled => TRUE,
auto_drop => TRUE
);
END;
/12345678910111213141516171819202122232425262728293031323334
DECLARE
l_user VARCHAR2(30) := 'SCOTT';
l_db_link VARCHAR2(30) := 'my_link';
l_cursor PLS_INTEGER;
BEGIN
l_cursor := sys.DBMS_SQL.open_cursor(security_level => 2);
sys.DBMS_SQL.parse(c => l_cursor,
statement => 'DROP DATABASE LINK ' || l_db_link,
language_flag => sys.DBMS_SQL.native,
schema => l_user);
sys.DBMS_SQL.close_cursor(c => l_cursor);
END;
/
DECLARE
l_user VARCHAR2(30) := 'SCOTT';
l_db_link VARCHAR2(30) := 'my_link';
l_cursor PLS_INTEGER;
BEGIN
l_cursor := sys.DBMS_SQL.open_cursor(security_level => 2);
sys.DBMS_SQL.parse(c => l_cursor,
statement => 'DROP DATABASE LINK ' || l_db_link,
language_flag => sys.DBMS_SQL.native,
schema => l_user,
container => 'PDB1');
sys.DBMS_SQL.close_cursor(c => l_cursor);
END;
/Please to add comments
No comments yet. Be the first to comment!