0

I have a db link from DB1 to DB2. I have a job that runs a procedure that uses the contents on DB2, however, I would like the procedure to first check if DB2 is online and the dblink is working, if not then stop exit the procedure. Is there a function or command that checks if the remote database is online?

AYR
  • 1,139
  • 3
  • 14
  • 24

2 Answers2

1
declare 
  a int; 
begin
  execute immediate 'select count(0) from dual@dblink' into a;
  -- DBlink online
exception
  -- DBlink offline
end;
Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
1

My DBA recommended checking the output from
sqlplus user/passwd <<EOF
select sysdate from dual ;
EOF

Karel Adams
  • 185
  • 2
  • 19