Tuesday, 28 January 2014

DB LINK Create & Drop Through Procedure

CREATE or replace PROCEDURE scott.create_db_link AS
BEGIN
EXECUTE IMMEDIATE 'create database link LINK1 connect to scott identified by tiger using ''testdb''';
END create_db_link;
 /


exec scott.create_db_link;


col db_link format a50
select OWNER,DB_LINK,USERNAME from dba_db_links;
select * from dba_db_links where OWNER='SCOTT';



----drop database link scott.LINK1.REGRESS.RDBMS.DEV.US.ORACLE.COM;     ##
drop database link scott.LINK1.REGRESS.RDBMS.DEV.US.ORACLE.COM
                   *
ERROR at line 1:
ORA-02024: database link not found




----drop database link scott.LINK1;                                                 ##
drop database link scott.LINK1;
                   *
ERROR at line 1:
ORA-02024: database link not found



CREATE PROCEDURE scott.drop_db_link AS
BEGIN
EXECUTE IMMEDIATE 'drop database link LINK1';
END drop_db_link;
 /


exec scott.drop_db_link;


col db_link format a50
select OWNER,DB_LINK,USERNAME from dba_db_links;
select * from dba_db_links where OWNER='SCOTT';


drop procedure scott.create_db_link ;
drop procedure scott.drop_db_link;

No comments: