sql - Safe to compare DB data as Java String in Oracle? -


i'm pulling row data 2 oracle db's 2 string list. want compare these rows iterating through these lists , running basic .equals() comparison. safe/practical iterate through each list , compare each element via string comparison?

example:

list<string> resultset1 = <result set of rows db1 string list> list<string> resultset2 = <result set of rows db2 string list> 

//assuming result sets same size , point rows same primary/composite key

for(int = 0; < resultset1.size(); i++) {   if(resultset1.get(i).equals(resultset2.get(i))){    <do something>   } } 

as assumption states, result sets need same size. further, must both sorted in same order , include same set of keys. is, if recordset1 has {1,2,3,4}, recordset2 must have {1,2,3,4}. {1,2,4,3} won't cut it, nor {1,2,3,5}.

among other things, means list must use actual implementation class preserves order (or allows control order).

personally, approach joining data in database. if that's not possible (e.g., there 2 separate databases , don't have distributed query features in them), i'd use hashmaps instead of lists -- key of hashmap being key of data. way, iterate through keyset of resultset1 , corresponding value resultset2 using key. it'd clearer , less error prone.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -