Routine against hash file (need dummie's explanation)

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
xcasals
Participant
Posts: 12
Joined: Thu May 27, 2004 5:50 am

Routine against hash file (need dummie's explanation)

Post by xcasals »

Hi all! (again) (and again)
(and thank you for your support) (again) (and again)

I have a hash file whith two fields. DATE and WORKING_DAY. Data appear like this:

"2004-01-22" "1"
"2004-01-23" "1"
"2004-01-24" "0"
"2004-01-25" "0"
"2004-01-26" "1"
"2004-01-27" "1"

By the other side a have an ODBC feeding 2 dates (initial date and final date). I have to compute (throught a routine i supose) the working_days between this two dates. I don't know how to attack the hash file.

In fact, if we were talking about SQL it would be something like this:

SELECT SUM(WORKING_DAY) WHERE DATE > INITIAL_DATE AND DATE <= FINAL_DATE.

Thank you all.
xcasals.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... I would think you could do it via your SQL statement if you accessed the hash file with a UV stage.

Also consider turning it around. Use the hash as a source and the ODBC information as lookups. Bring in everything from the hash and constrain it to the rows that fall between the two dates. Then pass things through an Aggregator and do the sum there. Maybe not appropriate for your problem, but a technique to consider. Sometimes people don't realize that hash files make perfectly good sources for jobs. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
xcasals
Participant
Posts: 12
Joined: Thu May 27, 2004 5:50 am

Post by xcasals »

Thanks,
but i prefer to do it with code (access to the hash file i mean) as I will need to use that function several times.

;-)
chucksmith
Premium Member
Premium Member
Posts: 385
Joined: Wed Jun 16, 2004 12:43 pm
Location: Virginia, USA
Contact:

Post by chucksmith »

Perhaps, create a hash file whose key is date and whose data field is the number of working days since a specific start date. Now with two reads and a subtraction, you have your answer.

Otherwise, create a routine to count the number of work days between the two dates less weekends and holidays.
neena
Participant
Posts: 90
Joined: Mon Mar 31, 2003 4:32 pm

Post by neena »

Try Aggrigator stage ...
HTH
Neena
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you insist on doing it in code, and you want BETWEEN comparisons, why not use a B-tree file (Type 25) rather than a hashed file? Then you can skim left and right along the leaf nodes using the BSCAN statement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
xcasals
Participant
Posts: 12
Joined: Thu May 27, 2004 5:50 am

Post by xcasals »

Thank you all for all these ideas,

I thing I'm going to take the way of chucksmith.

xcasals
Post Reply