Page 1 of 1

Reading Hash file from within a DS routine

Posted: Mon Jul 09, 2007 11:49 pm
by kasgang
Hi

I have stored some prcalculated values within a Hash file. Now I want to use the values from the Hash file from within a routine.
Is there any way I can do it? Thanks to all in advance

Posted: Tue Jul 10, 2007 12:18 am
by ArndW
The commands you need to do this are in the BASIC Programmer's Guide and are OPEN, READ and CLOSE.

Example code:

Code: Select all

   OPEN '','MyHashedFileName' TO WorkFilePtr ELSE CALL DSLogFatal('Unable to open MyHashedFileName, status is "':STATUS():'".','')
   READ MyRecord FROM WorkFilePtr, "HashedFileKey"
   THEN
      {parse the MyRecord data and process as you wish}
   END
   ELSE
      CALL DSLogWarn('Record "HashedFileKey" not present in file.','')
   END
   CLOSE WorkFilePtr

Posted: Tue Jul 10, 2007 2:31 am
by kasgang
Thanks a ton ...

Posted: Tue Jul 10, 2007 5:31 am
by ray.wurlod
You can also use the Trans() function - also in the DataStage BASIC manual. This may be easier if there is only a single record that needs to be accessed by the routine.