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.

2 Answers 2


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.

  • 1
    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, 2011 at 20:33
  • 11g documentation download.oracle.com/docs/cd/E11882_01/server.112/e17120/… Jan 12, 2011 at 15:06

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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