Page 1 of 3

How to Clear a Hashed File Outside of Datastage Job?

Posted: Tue Sep 21, 2004 2:27 pm
by olgc
Hi there,

Before run a job, how can a hashed file be cleared which is created in a previous run? If it is not cleared, the looking up from the hashed file will be wrong.

Thanks,

Posted: Tue Sep 21, 2004 2:37 pm
by kduke
There is a check box to clear the file. If the hash file is local to the project the ExecTCL("CLEARFILE MyHashFile"). This routine can be in a before job or called in a sequence. It is included in the SDK.

Posted: Tue Sep 21, 2004 2:38 pm
by ketfos
Hi,
You can check the option - Clear File before writing in Update Action window in Hashed File Input tab.


Ketfos

Posted: Tue Sep 21, 2004 3:08 pm
by olgc
It's too late to do so because the lookup looks the hashed file first and finds an entry. But that's not right. At the beginning, the hashed file should be empty in order to guarantee the correct result.

Thanks,

Posted: Tue Sep 21, 2004 3:31 pm
by kduke
I told you wrong it is "CLEAR.FILE MyHashFileName". This will work in a before job routine.

Posted: Tue Sep 21, 2004 4:16 pm
by ray.wurlod
CLEAR.FILE will work via ExecTCL only if the hashed file was created in an account.

If the hashed file was created in a directory you need the operating system variant (clear.file) with the pathname of the hashed file.

Code: Select all

$DSHOME/bin/clear.file pathname
executed via ExecSH (for UNIX) or ExecDOS (for Windows).

Posted: Wed Sep 22, 2004 9:36 am
by olgc
Thanks, It works.

Posted: Wed Sep 22, 2004 2:10 pm
by leomauer
ray.wurlod wrote:CLEAR.FILE will work via ExecTCL only if the hashed file was created in an account.

If the hashed file was created in a directory you need the operating system variant (clear.file) with the pathname of the hashed file.

Code: Select all

$DSHOME/bin/clear.file pathname
executed via ExecSH (for UNIX) or ExecDOS (for Windows).
I tryed it at UNIX prompt it did not work:
$ clear.file /mount/test/sa/hash/CST010_hash
Unable to open VOC file.
*** Processing cannot continue
. ***

What do you think gone wrong?

Posted: Wed Sep 22, 2004 4:19 pm
by ray.wurlod
I negelected to mention that this command must be executed while attached to a DataStage project directory (an "account"). Mea culpa. :oops:

Posted: Wed Sep 22, 2004 4:52 pm
by ketfos
Hi Ray,
---------------------------
CLEAR.FILE will work via ExecTCL only if the hashed file was created in an account.

If the hashed file was created in a directory you need the operating system variant (clear.file) with the pathname of the hashed file.
Code:
$DSHOME/bin/clear.file pathname
executed via ExecSH (for UNIX) or ExecDOS (for Windows).
------------------------------------

You had mentioned correctly in your last but one reply that
Clear.file works for hashed file created throught he account.

Leomauer - Can you see the hash file iname listed n the Unix Directory path you are using in clear.file command?

Ketfos

I think the file path might be incorrect. That is why it dosenot clear the file.

Posted: Wed Sep 22, 2004 8:26 pm
by kcbland
Sorry for not piping up earlier, the method you need to use sounds a little hokey, but it works. What you do is create the hash file, then copy the contents of the empty hash file subdirectory into a parking space. Whenever you need to clear the hash file, simply recopy the empty DATA.30 and OVER.30 files back into the hash file subdirectory from your parking spot.

Posted: Thu Sep 23, 2004 6:32 am
by leomauer
ketfos wrote:Hi Ray,
---------------------------
CLEAR.FILE will work via ExecTCL only if the hashed file was created in an account.

If the hashed file was created in a directory you need the operating system variant (clear.file) with the pathname of the hashed file.
Code:
$DSHOME/bin/clear.file pathname
executed via ExecSH (for UNIX) or ExecDOS (for Windows).
------------------------------------

You had mentioned correctly in your last but one reply that
Clear.file works for hashed file created throught he account.

Leomauer - Can you see the hash file iname listed n the Unix Directory path you are using in clear.file command?

Ketfos

I think the file path might be incorrect. That is why it dosenot clear the file.
I usually do not type the file name, but copy/paste it from the screen. Therefore the path/name is correct. When I simply recall the command and replace clear.file with ls -l i see the file.
I would like to make it work. It is a usefull feature. Our people are creating special DS jobs to load empty file into hash. I do not like it.
Ray. What does "attached to a DataStage project directory" means in layman terms?
Thanks.

Posted: Thu Sep 23, 2004 6:50 am
by chulett
In layman's terms it should mean that it would work as long as it is issued from inside a 'job', not directly from the command line. So, a piece of job control code or a routine (before job, let's say) could use DSExecute to issue the command and then it would work.

Only way I can see accomplish what Ray is saying. :?

Posted: Thu Sep 23, 2004 8:58 am
by leomauer

Code: Select all

sys="UNIX"
Command="/dsadm/Ascential/DataStage/DSEngine/bin/clear.file ":fullHashFilepathname
*Command = "ls -l ":fullHashFilepathname

Call DSLogInfo("System: ":sys, "")
Call DSLogInfo("Command: ":Command, "")

Call DSExecute(sys, Command, ScreenOutput, SystemReturnCode)

Call DSLogInfo("Return Code: ":SystemReturnCode, "")
Call DSLogInfo("UNIX output: ":ScreenOutput, "")
Above is my code in job control.
It works when I execute:
Command = "ls -l ":fullHashFilepathname

But when
Command="/dsadm/Ascential/DataStage/DSEngine/bin/clear.file ":fullHashFilepathname
it aborts
Yet
$ ls -l /dsadm/Ascential/DataStage/DSEngine/bin/clear.file
-rwxr-x--x 1 dsadm datastg 1562767 Dec 08 2003 /dsadm/Ascential/DataStage/DSEngine/bin/clear.file

When aborting it does not even go as far as executing last two DSLogInfo (no problem when Command is ls)

Any idea?
Thanks.

Posted: Thu Sep 23, 2004 9:09 am
by chulett
So, you have no idea what the error message is? :? Have you tried Resetting the job via the Director? Sometimes that will get you some additional information labelled as "From previous run".