Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get some data from an external db and make some calculations with it in another db, is it possible to connect to an external db from a stored procedure? Thanks guys.


Im using Oracle and both databases are in the same server.

share|improve this question
up vote 10 down vote accepted

You want to use a Database Link (DBLink).

-- create tnsnames entry for conn_link
conn_link =
      (ADDRESS = (PROTOCOL = TCP)(HOST = perrito2)(PORT = 1521))
      (SERVICE_NAME = orabase)

USING 'conn_link';

SELECT table_name, tablespace_name FROM user_tables@conn_user; 

@conn_user on the end of a procedure or table name will tell the pl/sql engine to query the db link specified for that info.

share|improve this answer
Embedded deep within your PSOUG link is a reference to the DRIVING_SITE hint - performance of queries across DBLINKs can vary greatly - if you KNOW where most of the data processing is going to be done, be sure to set the DRIVING_SITE to the database where the data processing will be most efficient. – ScottCher Jan 4 '11 at 20:33

yes, you can, you can read data from about any database using dg4odbc. Any odbc complient database can be connect to and Oracle database providing you can find a working odbc driver for out platform. .odbc.ini and $ORACLE_HOME/hs/admin are your configuration locations.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.