Clear Down Hashed 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
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Clear Down Hashed Files

Post by nick.bond »

What is the best way to clear down hashed files.

I want a stage in a LoadAllFromScratch job/sequence which first clears down the hashed files that have been populated during all development and testing.

Do i need to write this in DS basic? If so what is the command?

Cheers, Nick.
Regards,

Nick.
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post by nick.bond »

Sorry to waist your time I think I have found the asnwer:

set up a before-job or before-stage subroutine, choose ExecTCL from the drop-down list, and execute the command:
CLEAR.FILE hashed_file_name
Regards,

Nick.
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

or You can check the box:'Clear file before writing' in which case DS will

make sure to build the hash file from scratch emptying the contents of it.

this is will be a good option if you have many hash files to clean, this will

also give you TRUE staging solution of not storing the look-up data from

the last run.

Just a thought !! Look into one of Ken's posting which supports this.
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post by nick.bond »

I'm using the same server job to load the one of historic load and the incremental load, just passing it different parameters. When I run the one off historic load i want to clear down the hashed files first. When I run the incremental load i don't want the hashed file cleared because I'm only appending new records to it. I'm doing it this way because I'm loading into SAP BW and don't want to extract all the records from SAP to build a new Hashed file each time the incremental load is used.

My problem now is how do i clear a hashed file from a sequencer?

Can I write a routine to do this and call the routine? if so what is the syntax/code? I keep getting compile errors.

Thanks, Nick
Regards,

Nick.
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

or create a dummy job which writes into the same hash file but zero number of records and in that job check the box: 'Clear file before writing' .


and introduce this job in between the two jobs you have in the sequencer. Does this sove your problem ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

bondcaliwood wrote:Can I write a routine to do this and call the routine? if so what is the syntax/code? I keep getting compile errors.
The syntax to clear a hash is dependant on exactly how it was created - inside a project, using a directory path, etc. Ray (or Ken?) has an excellent post out there explaining in detail this very issue with syntax examples, the whole nine yards - but I can't seem to find it at the moment and need to get out of here.

Can you post the syntax you are using?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Add a Routine Stage to your sequence where the clear needs to take place. Create a routine with two arguments: hash file name and clear switch job parameter. Have the routine issue a "CLEAR.FILE hashfilename" statement using the API DSExecute (search this forum) with TCL as the command type if the clear switch is set for historical, otherwise, have the routine just exit peacefully.

If your hash file is externally pathed, change to using a UNIX command type and use "rm -r fullyqualifiedpathhashfilename". Make sure that the job is set to create the hash file if needed.
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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kcbland wrote:Make sure that the job is set to create the hash file if needed.
Actually, as of 6.x at least this isn't needed. It will always create the Hash if it doesn't exist, even if the 'Create' box is not checked. So, it seems like the only reason to actually check it off nowadays is to override the defaults of a Dynamic hash.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

chulett wrote:
kcbland wrote:Make sure that the job is set to create the hash file if needed.
Actually, as of 6.x at least this isn't needed. It will always create the Hash if it doesn't exist, even if the 'Create' box is not checked. So, it seems like the only reason to actually check it off nowadays is to override the defaults of a Dynamic hash.
This "feature" actually sucks, because of another problem. Sometimes, when you rename a link going into a hash file stage, it "automagically" changes the name of the hash file to that of the link. Not checking create file used to cause the job to blow up, now it silently creates the errant file and continues on its merry way. This is tragic as a previous job is responsible for the creation of the file, and subsequent jobs add to or enrich the content. Since one of them is silently adding to "another" file, you lose all of that data and never see the error. Only during System Testing and inspection of the hash file work area (now a part of a standard checklist of things to do to approve) for misnamed hash files seem to catch these errors.

How about making buttons do what they are supposed to do? Is that toooo much to ask?
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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kcbland wrote:This "feature" actually sucks, because of another problem.
I agree, having actually run into the exact same situation you mentioned. After much wailing and gnashing of teeth, the errant hash file was discovered and terminated with Extreme Prejudice. :twisted:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply