Page 1 of 1

Clear the contents of a Hash file.

Posted: Fri Oct 14, 2005 5:23 am
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.

Posted: Fri Oct 14, 2005 5:27 am
by loveojha2
The Command is
CLEARFILE filename
the complete syntax is
CLEARFILE [file.variable] [ON ERROR statements] [LOCKED statements]

Posted: Fri Oct 14, 2005 5:35 am
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.

Posted: Fri Oct 14, 2005 5:37 am
by loveojha2
Use CLEAR.FILE filename :lol:

Posted: Fri Oct 14, 2005 5:53 am
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

Posted: Fri Oct 14, 2005 5:54 am
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

Posted: Fri Oct 14, 2005 6:13 am
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.

Posted: Fri Oct 14, 2005 6:18 am
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 \

Posted: Fri Oct 14, 2005 6:44 am
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.

Posted: Fri Oct 14, 2005 8:10 am
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.

Posted: Mon Oct 17, 2005 1:05 am
by Mayer
Hi All , Thanks for the suggestion its was a great help from you all.

Posted: Mon Oct 17, 2005 4:11 pm
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.