Handling empty hash files
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 153
- Joined: Thu May 11, 2006 1:52 am
- Location: Bangalore
Handling empty hash files
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
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
-
- Participant
- Posts: 153
- Joined: Thu May 11, 2006 1:52 am
- Location: Bangalore
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
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
-
- Premium Member
- Posts: 232
- Joined: Fri Aug 04, 2006 1:20 am
- Location: Bangalore
You can always get the count of a Hashed file
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.
Code: Select all
Select Count(*) from HASHEDFILENAME;
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.
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
And you can establish the VOC pointer to the hashed file by executing:
Ex:
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:
Ex:
Whale.
Code: Select all
SETFILE Path_of_the_hashed_file\Hashed_File_Name Hashed_File_Name
Code: Select all
SETFILE C:\Hashed_Files\H_ITEM H_ITEM
Code: Select all
SETFILE Path_of_the_hashed_file\Hashed_File_Name Hashed_File_Name OVERWRITING
Code: Select all
SETFILE C:\Hashed_Files\H_ITEM H_ITEM OVERWRITING
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
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
I vote for it. The Best Way !!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.
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
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE