Getting Number of Columns of Hashed 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
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Getting Number of Columns of Hashed File

Post by DS_SUPPORT »

I am writing a routine , which will get HashedFileName as Input and Check the Values in all columns of it. By default the hashed file will contain 1 row, and i wanted to see all the values of all columns is there in a specified range.

I am writing something like this

Code: Select all

OpenPath FilePath:HashFileName TO HashVal
Then
Read Record From HashVal, CurrID
            Then
               RVal = Record
               Print Record
               ColCount = DCount(RVal,@FM)
              * Print DCount(RVal,@VM) : "@VM Count"
              * Print DCount(RVal,@FM) : "@FM Count"
              * Print DCount(RVal,@TM) : "@TM Count"
              * Print DCount(RVal,@AM) : "@AM Count"
              * Print "ColCount" : ColCount
               Ans = ColCount
            End 

End

And once i get the number of columns i will loop it and read the value and will check whether it is there within our range values.

The Problem i am encountering is, The hashed File which i am giving as input contains 5 columns (3 Keys and 2 Non Keys), DCount (@FM) gives me 2 , where as i need 5 as the Output, what value i have to use for counting the number of columns in the Hashed File, or is there any other way to read the Hashed File and check the number of Column and its values?
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

And after getting the column count, I will loop all the columns, i want to read the column value like Record<1>, so whether i will be able to read the Key columns and its value also like this.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

DataStage hashed files have only 1 key column. Your 3 keys are actually just one dynamic array string in CurrID that contains some separator character; thus the 2 column result returned by your DCOUNT() is correct.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try this.

Code: Select all

ColCount = DCount(Convert(@TM,@FM,RVal),@FM)
The single physical key is typically made up of values separated by text mark characters (@TM).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Thanks for the Replies. Using DCount(Convert(@TM,@FM,RVal),@FM) doent give me the desired results, So I have used two loops one for validating the Keys and one for Validating Non Keys.

Code: Select all

            Read Record From HashVal, CurrID
            Then
               RVal = Record
******* Loop and Validate the Key Fields
               KeyColCount = DCount(CurrID,@TM)
               For I = 1 to KeyColCount
                   CurrKey = Field(CurrID,@TM,I)
                   Print CurrKey : "I Val" : I
******* Do the Required Validations here
               Next
***** Loop and Validate the Non Key Fields
               ColCount = DCount(Record,@FM)
               For I = 1 to ColCount
                  CurrCol  = Field(Record,@FM,I)
                   Print CurrCol  : "Col  Val : " : I
***** Do the Required Validations here
               Next
               Ans = KeyColCount 
            End 
And by doing this, i am able to fetch all the column values. And now this leads me to one more requirement, Is there any way to get the Column Names for the Directory Pathed Hashed Files. I dont want to create the VOC as this will be generic routine, and it can be called for validating any Hashed Files. So it will be more like creating VOC entry for all the Hashed Files.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

To open the dictionary with OpenPath, specify "D_hashedfilename" as the entryname portion of the pathname.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply