Handling empty hash 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
sumesh.abraham
Participant
Posts: 153
Joined: Thu May 11, 2006 1:52 am
Location: Bangalore

Handling empty hash files

Post by sumesh.abraham »

Hi All,

I've a DataStage job which uses an ODBC stage to call a stored procedure and the count of the records is stored in a hash file. This hash file is looked up in a second job which calls a routine for some functionality. If the stored procedure doesn't reurn any records, the hash file will be empty and the second job doesn't call the routine since zero rows are passed from the hash file to the transformer which calls the routine.

How to make sure that the hash file will hold a count of 0 if the stored procedure doesn't return any record(without changing the stored procedure).

Any help will be appreciated.

Thanks,
Sumesh
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi Sumesh,
Hashed file is Datastage entity and Stored procedure is Database entity. So you need to find, where that Hashed file is getting loaded from. There you need to tweak to give the default as zero.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sumesh.abraham
Participant
Posts: 153
Joined: Thu May 11, 2006 1:52 am
Location: Bangalore

Post by sumesh.abraham »

Kumar,
Thanks for the reply.

I'm getting the records from the stored proc and finds the count by aggregator and stores the count in a hash file. So when stored proc returns zero records, zero rows will be passed from the ODBC stage and hence the hash file will be empty. When this hash file is used for lookup, the routine in the second job will not be called.

Is there any way to check whether the hash file is empty and if empty, insert a value of 0 to hash file.

Thanks
Sumesh
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

You can always get the count of a Hashed file

Code: Select all

Select Count(*) from HASHEDFILENAME;
So here you can write a routine and check the rowcount of Hashed file, and based upon the result you can proceed your second job.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can run the above query in your routine itself using DSExecute(). Also if your hashed file was created in a directory path outside the project directory then you need to VOC pointer to the hashed file before using the select count(*) on it.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

And you can establish the VOC pointer to the hashed file by executing:

Code: Select all

SETFILE Path_of_the_hashed_file\Hashed_File_Name Hashed_File_Name
Ex:

Code: Select all

SETFILE C:\Hashed_Files\H_ITEM H_ITEM
If the VOC entry already exists, and you want to refresh the VOC to the same hashed file because the hashed file now exists in a different path, then execute:

Code: Select all

SETFILE Path_of_the_hashed_file\Hashed_File_Name Hashed_File_Name OVERWRITING
Ex:

Code: Select all

SETFILE C:\Hashed_Files\H_ITEM H_ITEM OVERWRITING
Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Why involve a hashed file at all? It seems worthless as a Sequential file is easier to use.
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
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

If I were you, I would store the count of the records using DSSetUserStatus.
I feel this to be a much easier route to take.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

narasimha wrote:If I were you, I would store the count of the records using DSSetUserStatus.
I feel this to be a much easier route to take.
I vote for it. The Best Way !!
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Post Reply