routine to get value from hashed file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
jasper
Participant
Posts: 111
Joined: Mon May 06, 2002 1:25 am
Location: Belgium

routine to get value from hashed file

Post by jasper »

Hi,
from examples here and there I've created a routine to get data from a hashed file. This routine will be used in a workflow:
-fillhash
-startloop
-read data from hash into variables
-call some jobs for these variables
-end loop

As you will see in the code below, the routine now asks for the hashfile, the keyvalue and the column. But: the column is a numeric value.
I would like to change this to column-name.
Any idea how this can be done?

Code: Select all

*
* Executes a lookup against a hashfile, it will return the value from column in the other param
*
* Input Parameters :   hashfile: hashfile in which to look (always in projectdir)
*                      keyvalue:value in the keycolumn of this hashfile
*                      column : columnnumber of which the value should be returned
* Return  Values: If no record found, return value is:     "**RECORD NOT FOUND**".
*                 If hash file not found, return value is: "**TABLE NOT FOUND**"
*
*		  Note that the above strings may be localised.
*

    RoutineName = 'getvaluefromanyhash'

    Common /HashLookup/ FileHandles(100), FilesOpened

    Deffun DSRMessage(A1, A2, A3) Calling "*DataStage*DSR_MESSAGE"

    HashTable = hashfile
    HashKey = keyvalue
    ColumnPosition = column
    

    
 	
    * Attempt to find the table name in our cache.
    Locate HashTable in FilesOpened Setting POS Then
     	Read Rec From FileHandles(POS), HashKey Then
            Ans = Rec<ColumnPosition> 
        End Else
            Ans = DSRMessage("DSTAGE_TRX_I_0010" , "**RECORD NOT FOUND**", "" )
        End
    End Else
	* Table is not in cache of opened tables, so open it.
        Open HashTable To FileHandles(POS) Then
            FilesOpened<-1> = HashTable
            Read Rec From FileHandles(POS), HashKey Else
                Rec = DSRMessage("DSTAGE_TRX_I_0010" , "**RECORD NOT FOUND**", ""  )
            End
            If  Rec <> DSRMessage("DSTAGE_TRX_I_0010" , "**RECORD NOT FOUND**", ""  ) Then
                Ans = Rec<ColumnPosition>
            End Else
                Ans = Rec
            End
        End Else
            Rec = DSRMessage("DSTAGE_TRX_I_0011" , "**TABLE NOT FOUND**", "" )
            Ans = Rec
        End
    End
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Hashed files are not supported in parallel jobs. You have posted in the parallel forum and specified a parallel job type.

Post the question in the server forum if it is related to server routine (which the language appears to suggest).
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