How to compare two select quieres parallelly from 2 different Dbs(pls help)
I have tried doing it from my previous question :
pls look at this link and help me with parallelly looping 2 different databases :-
http://forums.sun.com/thread.jspa?threadID=5368358&messageID=10620723#10620723
i am attaching the code i wrote to achieve it , but i know i am not right in looping : pls help me with this :-
Query ABC Oracle database with the following:
ResultSet resultSet = statement.executeQuery("select sno,Description" +
"from TableA ");
while(resultSet.next()) {
SerialCode= resultSet.getString(1);
Description= resultSet.getString(2);
newcode= Integer.parseInt(SerialCode);
// Query DEF Sybase database with the following:
ResultSet resultSet1 = statementsyb.executeQuery("select Type,Text from TableB");
while(resultSet1.next()) {
TypeCode = resultSet1.getInt(1);
TextDescription = resultSet1.getString(2);
if ((newcode == TypeCode) && (Description.equals(TextDescription))) {
}else if ((newcode == TypeCode) && (!(Description.equals(TextDescription))){
// Prepare a statement to update the record
String Sql = ("UPDATE TableB SET TextDescription = ' " + Description + " ',Abrevation = ' " + Description.substring(0,20) + "', " + .......................");
// Execute the update Statement
Count_updatedDescription_DEF = statementsyb.executeUpdate(Sql);
}else if (newcode > TypeCode) {
// Prepare a statement to insert a record
String Sql1 = ("INSERT INTO TableB(............) " +
"VALUES(...............)");
// Execute the insert statement
Count_NewType_DEF = statementsyb.executeUpdate(Sql1);
}else if (newcode < TypeCode) {
// Prepare a statement to delete a record
String Sql2 = ("DELETE from TableB where Type> '" + newcode + "'");
// Execute the delete statement
Count_DeletedType_DEF = statementsyb.executeUpdate(Sql2);
// Prepare a statement to insert a record
String Sql3 = ("INSERT INTO TableB ...........");
// Execute the insert statement
Count_NewType_DEF = statementsyb.executeUpdate(Sql3);
resultSet1.close();
resultSet.close();
{code}
pls help
Please continue the conversation in your original thread: [http://forums.sun.com/thread.jspa?threadID=536835]
Thanks!
Similar Messages
-
How to compare index names and columns from different user?
I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
WITH t AS
(SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
cnt
FROM ( SELECT index_owner,
index_name,
listagg (column_name, ',')
WITHIN GROUP (ORDER BY column_position)
indexed_cols
FROM dba_ind_columns
WHERE index_name='XPKTBL_A'
GROUP BY index_owner, index_name))
SELECT CASE
WHEN cnt > 1 THEN 'Indexes are different'
WHEN cnt = 0 THEN 'Indexes dont exist'
WHEN cnt > 1 THEN 'Indexes are identical'
END
commnt
FROM t
Result:
Indexes are different
but Actually if you check below they are same After when I run this query:
SELECT index_owner,
index_name,
listagg (column_name, ',') WITHIN GROUP (ORDER BY column_position)
indexed_cols
FROM dba_ind_columns
WHERE index_name='XPKTBL_A'
GROUP BY index_owner, index_name;
Result:
Index_owner
Index_name
Index_cols
USER1
XPKTBL_A
FIELD_A1
USER2
XPKTBL_A
FIELD_A1Hi,
Erhan_toronto wrote:
I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
WITH t AS
(SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
So index_owner is 'USER1' in one case, and 'USER2' in the other; right?
A string that starts with 'USER1' will be distinct from a string that starts with 'USER2', no matter what the rest of the string contains. Maybe you don't want to compare the owners, or maybe you meant to use some other column (such as table_name) instead of index_owner).
I hope this answers your question.
If not, post a little sample data (CREATE TABLE, CREATE INDEX and CONNECT statements), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
How to compare two rows from two table with different data
how to compare two rows from two table with different data
e.g.
Table 1
ID DESC
1 aaa
2 bbb
3 ccc
Table 2
ID DESC
1 aaa
2 xxx
3 ccc
Result
2Create
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
How to compare two views/tabels from two systems via RFC
Hello
How to compare two views/tabels from two systems via RFC. I know there is a transactio or program but whichHi Tina,
You can use a trnasactions like SCMP, SADJ or SCU0 - all tools to do comparison of customizing objects across clients/systems using RFC.
Details of these tools, their usage and functionalities are available in the Help Portal -
[http://help.sap.com/saphelp_47x200/helpdata/en/70/1accb7fab511d18e0f0000e8a48612/frameset.htm]
Best Regards,
Rekha -
How to compare two rows in PL/SQL?
Hi All,
How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?
Any feedback would be highly appreciated.PhoenixBai wrote:
Hi All,
How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?What "rows" are you referring to?
If you're talking of rows within a PL/SQL associative array there are techniques as described in the documentation... e.g.
SQL> ed
Wrote file afiedt.buf
1 declare
2 type v1 is table of number;
3 r1 v1 := v1(1,2,4);
4 r2 v1 := v1(1,2,3);
5 begin
6 if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
7 dbms_output.put_line('Same');
8 else
9 dbms_output.put_line('Different');
10 end if;
11* end;
SQL> /
Different
PL/SQL procedure successfully completed.
SQL> ed
Wrote file afiedt.buf
1 declare
2 type v1 is table of number;
3 r1 v1 := v1(1,2,3);
4 r2 v1 := v1(1,2,3);
5 begin
6 if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
7 dbms_output.put_line('Same');
8 else
9 dbms_output.put_line('Different');
10 end if;
11* end;
SQL> /
Same
PL/SQL procedure successfully completed.
SQL>If you're talking about rows on a table then you can use the MINUS set operator to find the rows that differ between two sets of data...
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
14 rows selected.
SQL> select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
7 rows selected.
SQL> select * from emp
2 minus
3 select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7 rows selected.If you actually need to know what columns data is different on "non-matching" rows (based on your primary key) then you'll have to compare column by column. -
How to compare two Universes ?
Post Author: Shrikant
CA Forum: Administration
Hi.. all I want to compare two universes of different data mart to check the table structure. Can anybody please tell me how to compare two Universes of different Datamarts?How i can achive this usinig BusinessObjects Enterprise XI Release 2 ??
Thanks in advance.
ShrikantCreate
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
How to compare two Universes of two different Datamarts?
Post Author: Shrikant
CA Forum: Integrated Solutions
Hi.. all I want to compare two universes of different data mart to check the table structure. Can anybody please tell me how to compare two Universes of different Datamarts?How i can achive this usinig BusinessObjects Enterprise XI Release 2 ??
Thanks in advance./*does record 1 have friend*/
WITH t AS
(SELECT 1 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 2 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 3 AS Id, 'a' AS NAME, 'type2' AS Col FROM Dual)
SELECT count(*) as YesNo
FROM t T1
WHERE T1.Id = 1
AND (T1.Name, T1.Col) IN (SELECT T2.Name, T2.Col FROM T t2 where t2.ID != T1.Id);
1
/*does record 3 have friend*/
WITH t AS
(SELECT 1 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 2 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 3 AS Id, 'a' AS NAME, 'type2' AS Col FROM Dual)
SELECT count(*) as YesNo
FROM t T1
WHERE T1.Id = 3
AND (T1.Name, T1.Col) IN (SELECT T2.Name, T2.Col FROM T t2 where t2.ID != T1.Id);
0
*/ -
??how to compare two resultsets??
hi all!
i need to find out whether two resultsets contain the same data.
the only way i know how to do it in java is to put them into a while loop and fetch the contents first and then compare the contents.
but is there an easier way to compare resultsets?
does anyone know how to compare two resultsets without extracting the data?
the code example here executes two identical queries on an oracle database, compare and print the resultsets.
public ResultSet getResultset(String query)
ResultSet rs=null;
try { rs=Stmt.executeQuery(query); }
catch(Exception e) { e.printStackTrace(); }
return rs;
public static void main(String[] args) {
ResultSet r1=null;
ResultSet r2=null;
try {
database db = new ddatabase();
r1=db.getResultset("Select 'name' from person");
r2=db.getResultset("Select 'name' from person");
if (r1 == r2) {
System.out.println("ok");
System.out.print(r1);
System.out.println();
System.out.print(r2);
else {
System.out.println("not ok");
System.out.print(r1);
System.out.println();
System.out.print(r2);
jdbc.cleanup();
catch(Exception e) {e.printStackTrace();}
and here is the output:
F:\java rs_compare
not ok
oracle.jdbc.driver.OracleResultSetImpl@4413ee
oracle.jdbc.driver.OracleResultSetImpl@786e64
as you can see the resultsets are different though the data they contain have to be the same.
so the 'if(resultset#1 == resultset#2)' does not work.
thanks for any help
best regards
5ithl0rdDon't cross-post.
I'll bet ResultSet implementations don't override equals() to provide "deep equals" behavior, in which case it'll be no different than using "==".
It's a bad idea to compare two ResultSets this way. You'll have to load both into objects or data structures and compare those in a "deep" way.
Besides, the ONLY way two ResultSets could be different, given the same query, would be if there were multiple clients that could write to the table between queries and change the underlying data. If your two queries are sufficiently isolated, I'd say that the same query will return the same ResultSet.
% -
How to compare two stored procedure
I have two oracle database and each database have stored procedure
How to compare two stored procedure?
What is the command to compare the stored procedure?select line, text
from user_source
where name='....'
minus
select line, text
from user_source
where name='....'
should do nicely.
Or: get the procedure text to a file using dbms_metadata.get_ddl (9i and higher) and run diff (Unix) or fc (Windhoze) on it.
You are a bit scarce on details.
Better still: implement source control.
Sybrand Bakker
Senior Oracle D.B.A. -
How to Compare two Dates in java
How to Compare two Date Field after getting the values from jTextField1.getText() and jTextField2.getText().
Date d1=DateFormat.getDateInstance().parse(yourstring1);
same for d2
d1.compareTo(d2);
could be that i misrememberd the exact naems of some functions or mixed up something in the equence of d1= -
Hi,
I have two similar css files and want to have a third version with some properties from one and some from other file. But I do not know how to compare two files in DW. Is there some hint or program?
Thanks.
reagrds, Natasahans-g. wrote:
It might sound strange, but for this I use a word processing program. I build a table with three columns (in portrait or in landscape mode depending on your needs). I set the paragraph marks so that I can compare the paragraphs. The new combinated version I copy into the third column. And then the way is free to copy the new compounded text into your new DW file.
Hans,
Have you tried WinDiff, WinMerge, Beyond Compare (my choice) or Compare It! or several others which automate much of the manual system outlined above?
http://www.scootersoftware.com/moreinfo.php?zz=screenshot&shot=TextCompare
http://www.scootersoftware.com/moreinfo.php?zz=screenshot&shot=TextMerge
These diff tools can then be used in conjunction with DW.
http://help.adobe.com/en_US/dreamweaver/cs/using/WSc78c5058ca073340dcda9110b1f693f21-7edda .html
Just a thought. -
How to compare two different environments
Can any please tell me how to compare two environments like DEVL to TEST?
I know how to compare a project(like DEVL to TEST) but i want to see all the changes in all the objects between two different environments.
Please help me.
Thank you.That is really a good piece of information.
Does it really matter where we are comparing from?
i will explain,let us say we have DEV and TST environment.
let us say both has same project name and the same number of objects but inside the object they may be different(like number of fields in the same record in both environments).
Now we want to have a compare report between those environments.
We can do in two different ways, right?
(1. source DEV, Target TST)
(2. source TST, Target DEV)
will the result get changed in both the cases?
(except like following)
(first case souce target)
( absent *changed)
(second case would be like following)
( souce target)
( *changed absent)
(but i gess the number of rows in both the cases does not get changed)
let me know if you can not understand the question. sorry about the confusing explanation -
How to compare two files in java & uncommon text should print in text file.
Hi,
Can any one help me to write Core java program for this.
How to compare two files in java & uncommon text should print in other text file.
thanks
SamHi All,
i m comparing two HTML file.. thats why i am getting problem..
import java.io.BufferedReader;
import java.io.FileReader;
public class textmatch{
public static void main(String[] argv)
throws Exception{
BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
String s;
String y;
while ((s=fh.readLine())!=null)
if ( s.equals(y=sh.readLine()) ){
System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
sh.close();
fh.close(); }
thanks
Sam -
How to compare two files in Java & uncommon text should print in Diff text
Hi All,
can any one help me to write a java program..
How to compare two files in Java & uncommon text should print in Diff text file..
Thanks
SamHi All,
i m comparing two HTML file.. thats why i am getting problem..
import java.io.BufferedReader;
import java.io.FileReader;
public class textmatch{
public static void main(String[] argv)
throws Exception{
BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
String s;
String y;
while ((s=fh.readLine())!=null)
if ( s.equals(y=sh.readLine()) ){
System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
sh.close();
fh.close(); }
thanks
Sam -
How to compare two xml schemas
Hello guys,
How to compare two xml schemas? is there any tool for that?
Thanksinadvance
kavita//XML Files may be compared with the oracle.xml.differ.XMLDiff class.
A file consisting of the differences in the xml files gets generated. An XSLT to convert one file to the other also gets generated.
Maybe you are looking for
-
I'm using MAC OS X 10.4.7, Macbook. I'm trying to connect to my windows PC that is connected to a printer, wirelessly. I've enabled sharing on the windows PC side. Problem is when i'm trying to add printer as an IPP (Internet protocol printing), it d
-
Error getting CSS support information for driver [HsvAdmDriver]
Hi all, we have installed HFM on Win2003 x64 EE server. Everything is working correctly, but we are not able to create a connection to HFM data source in Web Analysis. Following error occurs: 4010 Error: Error Getting CSS Support Information For Driv
-
What ESB adapter can pass a message from JMS service to outside service?
1. we are running ESB from SOA 10.1.3.1 on linux 2. we have XML message passed to JMS deployed at the local OC4J 3. we need this XML message passed to an outside service. What will be the adapter to use as outbound from JMS? TIA
-
A song I just bought won't play in my iTunes?
I've never had this problem before though some of my friends have and now it's happening to me. I just bought a song probably 15 minutes ago and whenever I click on it to play it it skips to the next song. I tried playing it in quicktime and quickt
-
Scenario for report to report interface
hi experts i want to know how you people used R/ RI report to report interface in your project, explain me ur experince working with RRI, thank you