| |

VerySource

 Forgot password?
 Register
Search
View: 822|Reply: 4

Ask a judgment statement.

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-27 14:40:01
| Show all posts |Read mode
There is a backup database B, which will not be open to us until the backup is complete, but sometimes it will not open for that day.

I have a database A, and a DBLINK to database B is built on A.

Run an application on A, and use the data of B, such as:
select * from all_tables @ B

How can I tell if database B is already available, I tried using an exception, as follows:
declare
aa number (10);
begin
select count (*) into aa from all_tables @ B where rownum <2;
exception
when others then
dbms_output.put_line ('Database is not ready');
end;

But it failed to catch, and the error reported was ORA-00942: The table or view does not exist.
I wonder if there is any other way? consult.
Reply

Use magic Report

0

Threads

71

Posts

50.00

Credits

Newbie

Rank: 1

Credits
50.00

 United States

Post time: 2020-2-21 21:15:01
| Show all posts
First determine whether db_link is working?

select sysdate from dual @ B;
If there is a return value, the explanation is passed. Otherwise, you need to see what the problem is, it may be a network problem, it may be that tnsnames.ora is not configured well

If there is a return value, you need to create a public synonym for the table in the remote database that you want to access.

Such as:
create publis synonym tabl_name for sys.tabl_name@B;
Reply

Use magic Report

0

Threads

71

Posts

50.00

Credits

Newbie

Rank: 1

Credits
50.00

 China

Post time: 2020-2-21 23:15:02
| Show all posts
But cannot catch

It is because your exception does not meet the conditions of the error.
Your exception should be insufficient permissions
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-22 21:15:01
| Show all posts
As said upstairs, the first thing is to see if you have any problems with <@ 连接 名> this way, including permissions; (you can see the access using B.all_tables) If there is no problem, from user_tables See if the table exists, and then compare the number of records.
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-29 21:30:01
| Show all posts
dblink does not catch exceptions when it is not easy to use
I use the returned 'ORA-00942: table or view does not exist' to determine whether the database is ready to connect (provided there must be a connected table)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list