compare 2 hash files

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
bdixon
Participant
Posts: 35
Joined: Thu Nov 20, 2003 5:45 pm
Location: Australia, Sydney

compare 2 hash files

Post by bdixon »

Hi,

Is there any way to compare 2 hash files without exporting them to a sequential file?
In addition is there any way to copy and paste rows out of a hash file?

Thanks
Brad
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Please outline your functional requirements. You can always have a job read hash file A and reference hash file B and output a sequential file of rows that are different, but you'll have to construct the constraint to do the comparison. You know, inA.col1 <> inB.col1 OR inA.col2 <> inB.col2 blah blah blah.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is there any way to do this with an Oracle table?

A hashed file is a table in the UniVerse database (aka the DataStage Engine database).

If the answer is no in one, it's no in the other.

If you want to access rows in a hashed file, you use the correct query languages, just like you would with other databases, except that there are two languages - Retrieve and SQL.

What, exactly, do you mean by compare? If you want to know whether every row in hashed file A has an exact counterpart in hashed file B, then you could use a DataStage job, or even a pair of UniVerse SQL commands to check each possible DIFFERENCE.

You need to specify your requirement more exactly.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

To find keys in one hash file and not in the other

Code: Select all

SELECT Hash1
NSELECT Hash2
SAVE.LIST NotIn2
GET.LIST NotIn2
LIST Hash1

Code: Select all

SELECT Hash2
NSELECT Hash1
SAVE.LIST NotIn1
GET.LIST NotIn1
LIST Hash2
NSELECT will build a list of keys not in the hash file. SAVE.LIST will save this list of keys so you can use it over and over with a GET.LIST command.

Code: Select all

open "HashFile1" to Hash1 else stop
open "HashFile2" to Hash2 else stop
DiffKeys = ''
SELECT Hash1
loop while readnext Key1
  RecDiff = @true
  read Rec1 from Hash1, Key1 then
    * Thx Ray Key2 was changed to Key1
    read Rec2 from Hash2, Key1 then 
      if Rec1 = Rec2 then
        RecDiff = @false
      end
     end
  end
  if RecDiff then 
    DiffKeys<-1> = Key1
  end
repeat
**
* write DiffKeys to some file
**
Kim.
Last edited by kduke on Thu Dec 18, 2003 9:08 am, edited 1 time in total.
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... or even a query (for example, for one side of the difference):

Code: Select all

SELECT hashedfile1 WITH EVAL "@RECORD" <> EVAL "TRANS('hashedfile2', @ID, -1, 'X')"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply