Posted: Wed Nov 01, 2006 9:02 am
Where exactly are you getting stuck?
As Craig suggested, go into the source code of UtilityHashLookup() change the specific code and make your own routine. Here ill help you with that.
Now copy paste this code into a new user-defined routine and name it 'myUtilityHashLookup'. Specify three arguments as Arg1, Arg2 and Arg3. And for Arg1, send in the fully qualified path of the hashed file name. Try this part first, and test it after compiling it. See if it retrieves the correct results. Lets get this part working first.
As Craig suggested, go into the source code of UtilityHashLookup() change the specific code and make your own routine. Here ill help you with that.
Code: Select all
*************************************************************************
* Copyright (C) 2004, 1997-2003 Ascential Software Corporation. All Rights Reserved. *
* This code may be copied on condition that this copyright *
* notice is included as is in any code derived from this source. *
*************************************************************************
*
* Executes a lookup against a hashed file using a key
*
* Input Parameters : Arg1 = Fully Qualified Path Of Hash Table
* Arg2 = Hash Key Value
* Arg3 = Column Position to return.
* If empty, return entire row in a dynamic array.
*
* 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 = 'myUtilityHashLookup'
Common /HashLookup/ FileHandles(100), FilesOpened
Deffun DSRMessage(A1, A2, A3) Calling "*DataStage*DSR_MESSAGE"
HashTable = Arg1
HashKey = Arg2
ColumnPosition = Arg3
PositionReturn = 0
* Determine if we are returning one column or entire row.
If Num(ColumnPosition) then
ColumnPosition = Int(ColumnPosition)
If ColumnPosition > 0 and ColumnPosition < 99999 Then
PositionReturn = 1
End
End
* Attempt to find the table name in our cache.
Locate HashTable in FilesOpened Setting POS Then
Read Rec From FileHandles(POS), HashKey Then
If PositionReturn Then Ans = Rec<ColumnPosition> Else Ans = Rec
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.
OpenPath 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 PositionReturn And 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