Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select records on one database that match on another database? 1

Status
Not open for further replies.

Glowworm27

Programmer
Joined
May 30, 2003
Messages
587
Location
US
Hi all u Gurus

I have 2 databases, my local development database, and a Testing database at a remote location.

I want to query a table on my local database (TESTORACLE) and Join it with a Table on the Remote Database (MTADEV)

What I want to do is find the records that do Not match up on the remote database. To try to figure out what is missing on the remote system, to diagnose a bug.

Table layout is like this
Table Name = Labor_Dist
Fields =(Labor_Dist_ID -- (is the Key field)
, Company_Code
, SSN
, Acct_Unit
, Hours
, Pay_Sum_group
, Check_Date
, Universal_ID
, Work_Week_Ending_Date
, Create_Date
, Pay_Amt)

The tables are identical on both systems

Thanks in advance

George Oakes
Check out this awsome .Net Resource!
 
Hi,
After creating a database link to the remote table,
use the MINUS operator to determine what is not there:

Select * from Remote_table@dblink
MINUS
Select * from Local_table

will show all records that are in the Remote table but not in the Local one..
Reverse the order to see what is in the Local but not the remote.

You can use this method to create an exceptions table by using the Create Table <Tablename> as select * from
(Select * from Remote_table@dblink
MINUS
Select * from Local_table)
method.






[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Yeah I read the Docs, And I am not an Oracle Person, So some of it is hard to understand. Im a microsoft SQL guy that got stuck on this project.

And I have tried to set one up.

And I am receiving an error that ORA-12154: TNS:could not resolve service name

I can successfully connect using SQL plus to both my local database, and the remote database.

I have tried to create the link using this sql

Code:
CREATE DATABASE LINK Remote
CONNECT TO mtadev
IDENTIFIED BY mtadevpass
USING 'MTADEV.BFR.BFRCO.COM';

and here is what is in my tnsnames.ora file

Code:
MTADEV.BFR.BFRCO.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = Devtest.BFR.bfrco.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = mtadev)
    )
  )

and I receive the above error message.

I have even tried to create a link using this sql

Code:
CREATE DATABASE LINK MTADEV.BFR.BFRCO.COM
CONNECT TO mtadev
IDENTIFIED BY mtadevpass
USING 'MTADEV.BFR.BFRCO.COM';

With the same results
Thanks for the Help

George Oakes
Check out this awsome .Net Resource!
 
Hi,
Welcome to the most 'popular' error when first using Database links...

The link uses the TNSNAMES.ORA file on the database server to resolve the MTADEV.BFR.BFRCO.COM alias, not the one on your or any client's workstation..


If this is not the cause, let us know..

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks Turkbear,

I was able to get it working. My local database is only local in that it resides on our network, it was not on my local machine. So I spoke with another DBA and he said I needed to add the Remote Database info to the TNSnames.ora file on my local database server, and not my machine, like you had said.

Once that was done, it works perfectly now. Thanks and Star for you.

I thank you for your comments, and if I can return the favor in the future, I will be here for you.

Good day everyone.

George Oakes
Check out this awsome .Net Resource!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top