Batch Job for deleting 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
sumitgulati
Participant
Posts: 197
Joined: Mon Feb 17, 2003 11:20 pm
Location: India

Batch Job for deleting a hash file

Post by sumitgulati »

Hi All,

I have a Batch Job to delete a hash file. It takes hash file name as an input parameter.

Below is the code. "HashFileName" is the input parameter.

If IsNull(HashFileName) OR TrimF(TrimB(HashFileName)) = ''
Then
Call DSLogFatal("Hash file does not exist.", DeleteHashFileUtility)
End Else
CMD = "DELETE.FILE ": HashFileName
Call DSExecute("UV", CMD, Sysoutput, ReturnCode)
End

The problem is, when I delete a HashFile using this Batch Job and then run a select statement from the hash file in Command Interface I get the following message:
' Unable to open "" file. '
Ideally the message should be:
' DataStage/SQL: Table <HashFileName> does not exist. '

However, when I try to query the file using UtilityHashLookup it gives the result instead of saying "Table Not Found".

I guess the Batch Job is not at all deleting the file. It just puts a lock on the file because of which we are unable to query the file from Command Interface.

Is there anything wrong with the code?

Regards,
Sumit
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Sumit

You deleted the file. It no longer exists. It is just like drop table. If you want to clear the hash file then use CLEAR.FILE.
Mamu Kim
sumitgulati
Participant
Posts: 197
Joined: Mon Feb 17, 2003 11:20 pm
Location: India

Post by sumitgulati »

Kim, the problem is that the batch job is actually not deleting the hash file. I feel so because If I delete hash file using this batch job and then try to view the deleted hash files' data using UtilityHashLookup it does not throw an error message. Ideally it should throw a message saying "Table Not Found".

All I want is, when I delete a hash file using this batch job then no one should be able to access the file using either UtilityHashLookup or Commany Interface. The file should physically get deleted from UV. But this is not happening.

Regards,
Sumit
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'd suggest adding some code to check the results of your delete. Log what comes back in the 'Sysouput' array. Check the ReturnCode for a non-zero value. It might help shed some light on what is going on.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If the hashed file was created in a directory, rather than an account, then DELETE.FILE will not work; you'll need rm (UNIX) or del (Windows).

If the hashed file was created with a UV stage, then DELETE.FILE will not work; you'll need DROP TABLE.

If it was someone else who created the hashed file, there may be operating system permissions issues preventing you from deleting the hashed file. This is more likely to occur on UNIX (where umask is the culprit) than on Windows, but it's not impossible on the latter.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I am sorry. I misread the message. Craig and Ray both have good suggestions. Try those. It could be a permission problem.
Mamu Kim
sumitgulati
Participant
Posts: 197
Joined: Mon Feb 17, 2003 11:20 pm
Location: India

Post by sumitgulati »

Hi All,

Thanks for your suggestions. Ray, I tried DROP TABLE also but it doesn't work. I guess its permission issues only but I am not able figure out the exact problem.

Thanks again,
Sumit
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The error message
Unable to open "" file.
suggests that the parameter value is not being properly transmitted. Check that you have spelled it and used the same combination of upper and lower case letters in your code as in the parameter definition.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And add some code to check the results. Then you'll be able to stop guessing what the problem is. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
phanee_k
Charter Member
Charter Member
Posts: 68
Joined: Thu Nov 20, 2003 11:02 pm

delete a sequential file

Post by phanee_k »

Hi,
I want to delete a sequential file using the datastage job.How to delete it.

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You really should open a new topic, not just jump on the end of one that's sorta related. Then we'd know your DataStage version, operating system, etc. Plus, people looking for help on the same subject will have an easier time finding it, too! :wink:

That being said, you need to do this via your Operating System. Write a routine or make use of the before/after job ExecSH option to issue an rm or del of the sequential file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
1stpoint
Participant
Posts: 165
Joined: Thu Nov 13, 2003 2:10 pm
Contact:

missing a line

Post by 1stpoint »

You never assigned HashFileName to it's input parameter. DataStage does not automatically make parameters available.

Add this line to the top of your batch code:

Code: Select all

HashFileName   = DSGetParamInfo(DSJ.ME,"HashFileName",DSJ.PARAMVALUE)
Post Reply