Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Compare utility against two table

This is a discussion on Compare utility against two table within the Oracle forums, part of the Databases category; Hi All, I am new user, I have an issue. I am using oracle 9i, it has the two instances, on one instance there are some table and the other ...

Go Back   Geeks Talk > Databases > Oracle
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Oracle Oracle 9i & Oracle 10g Knowledge Base Learn and Share Oracle Technology related articles, white papers, tutorials / study materials, example codes, FAQ's, Tips and Tricks.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-10-2007
Junior Member
 
Join Date: Feb 2007
Location: India
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
anand.kr.singh is on a distinguished road
Compare utility against two table

Hi All,

I am new user, I have an issue.
I am using oracle 9i, it has the two instances, on one instance there are some table and the other instance there are table.
Let table 1 is from the instance one and table 2 is from instance 2. Now i have to make an compare utility against these two table and the compare will be on the column value (column value may be number, float, char, varchar and clob type) and it should be of exact match.
I want to log if there is some descripencies with all information.

If you have any queries, please let me know or you are founding that the example are not up to understanding i will modify in tabular form.

Thanks

Anand
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-15-2007
Expert Member
 
Join Date: Sep 2006
Location: India
Posts: 131
Thanks: 1
Thanked 21 Times in 20 Posts
Innila is on a distinguished road
Re: Compare utility against two table

Hi Anand,

As per my understanding to ur problem, this can be achieved by writing a procedure where u access the tables of both the instances and compare the column values.
I have just given a clue, probably u can make use of this & create ur own procedure.
For further queries, feel free to ask.

*** Mangai Varma ***
Reply With Quote
  #3 (permalink)  
Old 02-15-2007
Junior Member
 
Join Date: Feb 2007
Location: India
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
anand.kr.singh is on a distinguished road
Re: Compare utility against two table

Hi Mangai,
Thanks for ur suggestion, i have the same idea but i am unable to write it in the code form. Could you please write a sample query?

Thanks

Anand
Reply With Quote
  #4 (permalink)  
Old 02-19-2007
Expert Member
 
Join Date: Sep 2006
Location: India
Posts: 131
Thanks: 1
Thanked 21 Times in 20 Posts
Innila is on a distinguished road
Re: Compare utility against two table

Hi Anand,
The following is a sample query which will compare the values from 2 tables.
I have used 2 cursors (cursor for loop) so that its simple & easily understandable. I have also used dbms output messages so that the process flow & the result can be viewed during execution.

SAMPLE CODE
===========
Create or replace procedure comp as
l_empno number(5);
l_new_empno number(5);
cursor l_emp_cur is
select empno from emp where sal > 3000 and deptno = 10;
cursor l_emp_new_cur is
select empno from emp_new where sal > 3000 and deptno = 10;
begin
for l_emp_rec in l_emp_cur
loop
dbms_output.put_line('after notfound if l_empno '||to_char(l_emp_rec.empno));
for l_emp_new_rec in l_emp_new_cur
loop
dbms_output.put_line('after notfound if l_new_empno '||to_char(l_emp_new_rec.empno));
if l_emp_rec.empno = l_emp_new_rec.empno then
dbms_output.put_line('same empno'||l_emp_rec.empno||' & '||l_emp_new_rec.empno);
else
dbms_output.put_line('different empno'||l_emp_rec.empno||' & '||l_emp_new_rec.empno);
end if;
if l_emp_new_cur%notfound then
exit;
end if;
end loop;
if l_emp_cur%notfound then
exit;
end if;
end loop;
end;
/

Using the above sample code, u can generate ur code with more enhancements whichever u require.
Hopefully its clear & understandable :-)

*** Mangai Varma ***

Last edited by Innila; 02-19-2007 at 01:53 AM. Reason: Formatting purpose
Reply With Quote
Reply

  Geeks Talk > Databases > Oracle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Compare values of column in a table JobHelper SQL Server 4 03-05-2009 05:37 AM
About Utility Remasri Windows 2 10-13-2008 10:43 AM
WinSnap is a small enhancement utility for taking and editing screenshots. JobHelper Geeks Lounge 0 01-31-2007 02:10 PM
What is this Utility or Command? StephenRaj Windows 1 09-24-2006 05:05 AM
What is the Utility used Bessie Unix/Linux 1 08-17-2006 02:10 AM


All times are GMT -4. The time now is 04:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved