Page 1 of 1

Find path to a hash file from a routine

Posted: Fri Nov 05, 2004 8:21 am
by tonystark622
Can anyone tell me how to find out what directory where a hash file lives from within a Routine? This is for hash files with a VOC record. I'm sure that there's a way to get the info from the VOC, but I don't know enough to know how to do this.

Thanks very much,
Tony

Posted: Fri Nov 05, 2004 9:37 am
by kduke

Code: Select all

Ans = ""
HashFileName = Arg1
open "VOC" to VOC else return
read VocRec from VOC, HashFileName then
   Ans = VocRec<2>
end


Posted: Fri Nov 05, 2004 9:39 am
by kduke
The second field in the VOC record has the path to the data side of a hash file. The third field is the path to the dictionary side of a hash file. Field one should have an "F". You should probably do error checking around all these little details but this is good enough. You should be able to finish it.

Posted: Fri Nov 05, 2004 10:14 am
by tonystark622
Thanks, Kim!

Before I saw your reply, I had it down to

Code: Select all

SELECT FILE.NAME FROM VOC WHERE TYPE = 'F' AND NAME = 'hash_name';

I called this from DSExecute("TCL",.....)
The output It seemed to put @FM throughout the return string whenever it wanted to wrap the data so it would fit within it's definition of a column. Like this:
File Name......

/appl/asc/DataS
tage/Projects/S
CM/Common/hash_
files/ha_hash

1 records listed.
So, the return string had 8 @FM values in it and 4 of them were within the actual path itself . I was trying to figure out how to parse out the path when I saw your reply.

Your way returns just the path without any extraneous @FM characters, no parsing required. Yeah!!!!

Thanks!
Tony

Posted: Fri Nov 05, 2004 5:52 pm
by ray.wurlod
A more general solution, that handles weird things that people might do (like use Q pointers or distributed files) is to use the FileInfo() function. This is able to return lots of different information about an open file, including its pathname.
Read all about it in the DataStage BASIC manual.