File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes how to compare rows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "how to compare rows" Watch "how to compare rows" New topic

how to compare rows

aliya sharma
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
I'm fairly new to java.
we have 2 databases (AS400 and SQL Server2000). There's a table in AS400 (named: ORHDR) with fields HORDNO, HOSTAT(P,W,X,) where x stands for "cancelled". In sql server, i have a table named Order with fields order_num, order_status(F,C,A).

i want to search the order table in SQL Server where order_status is "a" and then look up the corrosponding row in AS400. If the HOSTAT is "x", then update the field in SQL server to "C".

I know how to connect to both databases and select statement where order_status is "a". I just don't know how to compare that row with the corrosponding row of AS400 and then update the status adn keep doing this till the whole table is finished.
Any hints or sample code would be greatly appreciated. Thanks for your time

Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the JDBC forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
i can go for just one way. i dont know whether there is some better way.
but we can always get that row as String in our code and update the other on a certain condition. using some loops and if..else.

couldn't we??
I agree. Here's the link:
subject: how to compare rows
It's not a secret anymore!