Clear the contents of a Hash file.

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
Mayer
Participant
Posts: 10
Joined: Tue Aug 09, 2005 12:55 am

Clear the contents of a Hash file.

Post by Mayer »

What is the command that i can use to clear the contents of a Hashfile in DataStage Administrator Command Line Interface.

Note: I already know how to clear the contents of the file using the Clear file check box option in the job.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

The Command is
CLEARFILE filename
the complete syntax is
CLEARFILE [file.variable] [ON ERROR statements] [LOCKED statements]
Mayer
Participant
Posts: 10
Joined: Tue Aug 09, 2005 12:55 am

Post by Mayer »

Hi , Thanks for the reply but iam getting an error message when i try to execute this command saying "Verb CLEARFILE is not in your VOC",can you suggest on this .

Also let me know where can i search for this commands.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

Use CLEAR.FILE filename :lol:
Mayer
Participant
Posts: 10
Joined: Tue Aug 09, 2005 12:55 am

Post by Mayer »

Hi , I tried the CLEAR.FILE <Filename> but its giving error "Unable to clear Filename . Filename = "
I even tried with the complete path where the file is stored its giving me the same error.

eg.I issued this command.

CLEAR.FILE \imsv14\SAILDEV\hashfiles\Hash_BEngTaxonomyTermGroupKey
Mayer
Participant
Posts: 10
Joined: Tue Aug 09, 2005 12:55 am

Post by Mayer »

Hi , I tried the CLEAR.FILE <Filename> but its giving error "Unable to clear Filename . Filename = "
I even tried with the complete path where the file is stored its giving me the same error.

eg.I issued this command.

CLEAR.FILE \imsv14\SAILDEV\hashfiles\Hash_BEngTaxonomyTermGroupKey
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Mayer,

as you have noticed, the CLEAR.FILE command does not accept file paths, it expects to have the filename you use declared as some type of a file in the local VOC and is not meant for remote files. Instead of using a UNIX command I think it advisable to use a DataStage job to clear the file using the checkbox in the Hashed file stage to clear the file before writing to it.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You might use the following in a routine:

Code: Select all

OPENPATH '\imsv14\SAILDEV\hashfiles\Hash_BEngTaxonomyTermGroupKey' TO FileToClearPtr ELSE CALL DSLogFatal('Unable to open file','')
CLEARFILE FileToClearPtr ON ERROR CALL DSLogFatal('Uanble to clear file, status is "':STATUS():'".','')
CLOSE FileToClearPtr ;** this time Ray won't complain about my sloppy programming :)
Are you sure that you are on UNIX and not windows? If on unix, the path separator should be / and not \
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Externally pathed hash files do not work with most TCL commands unless you've used the SETFILE command with them.

Why clear it when you can just delete it? Is it because you're not wanting to incur creation overhead because you have a minimum modulos? One of the best reasons to use externally pathed hash files is the ability to easily delete them using operating system commands.
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 »

There's no ON ERROR clause for the OPENPATH statement in Arnd's code, yet this is where a system error is most likely to occur. :twisted: And I consider any use of DSLogFatal (or STOP or ABORT) (...or CHAIN) to be sloppy programming.

clearfile (in the DataStage bin folder) can be run from the operating system shell and does accept pathnames.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Mayer
Participant
Posts: 10
Joined: Tue Aug 09, 2005 12:55 am

Post by Mayer »

Hi All , Thanks for the suggestion its was a great help from you all.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Preferable is to use a small job (staying in the graphical paradigm). The job sends zero rows to the hashed file via a Hashed File stage, and the "clear file before writing" box is checked. Job runs in under one second.
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