Page 1 of 1

HashFileLookup

Posted: Thu Feb 15, 2007 8:54 am
by nibble
The UtilityHashLookup function only works on the VOC file.
If I Change the code to access one of my own HashFiles (Openpath instead of Open). I get an Improper Data Type error message, no matter what!!

The sections that fails is:
Read RecFrom FileHandlers(POS), KeyField Then
Ans = Rec<1>

Is there some magic to this ?
The error message is there even if I input NULL values on key column and column number...

Any ideas anyone ?

Posted: Thu Feb 15, 2007 8:59 am
by chulett
So, you copied the routine and the only change was from Open to OpenPath, yes? If that's the case, then the problem would not be with the routine itself but how you are calling it.

Can you provide an example of your calling syntax, please?

Posted: Thu Feb 15, 2007 9:01 am
by DSguru2B
How did you change that code. Make sure you only changed 'Open' to 'OpenPath'.

Re: HashFileLookup

Posted: Thu Feb 15, 2007 9:27 am
by ArndW
nibble wrote:...I get an Improper Data Type error message, no matter what!!...
This error message occurs when the file unit ("FileHandlers(POS)") is invalid - this occurs when your OPEN or OPENPATH has failed. Can you post that statement? You cannot just add the "path" to the the statement, as the syntax of both calls are different.

Posted: Thu Feb 15, 2007 10:19 am
by chulett
ArndW wrote:You cannot just add the "path" to the the statement, as the syntax of both calls are different.
Actually, you can as that's exactly what I've done here and it works just peachy. As noted, the syntax to call the routine is slightly different - you need to pass in the full path to the hashed file rather than just the VOC name. :wink:

Posted: Thu Feb 15, 2007 10:52 am
by ArndW
I am so used to using the OPEN '','FILENAME' syntax that I didn't check to make sure that the first parameter is actually optional until I went to check after reading Craig's statement. I stand corrected, the syntax of both statements is identical.

Posted: Thu Feb 15, 2007 1:24 pm
by ray.wurlod
It's a problem that you're remembering the old days (Prime), when the "" in the OPEN statement was necessary. If my memory serves it was made optional in about version 6 of Prime INFORMATION.

Waiting for nibble to respond with code and call before chasing any red herrings.

Changes to the code

Posted: Fri Feb 16, 2007 2:58 am
by nibble
I changed the value of the HastTable variable to contain path and filename:
HashTable = 'hasfilepath' : Arg1

When I do this change, the function manages to locate the file, if I don't, the function failes to locate the file.

The second change was change of Open statement to Openpath.

That's it !

The hasfile has one key column...

Chris.
chulett wrote:So, you copied the routine and the only change was from Open to OpenPath, yes? If that's the case, then the problem would not be with the routine itself but how you are calling it.

Can you provide an example of your calling syntax, please?

Calling the function

Posted: Fri Feb 16, 2007 3:16 am
by nibble
I haven't used the function in the ETL job yet, I only use the Test Function functionality.

Christer.
chulett wrote:So, you copied the routine and the only change was from Open to OpenPath, yes? If that's the case, then the problem would not be with the routine itself but how you are calling it.

Can you provide an example of your calling syntax, please?

Posted: Fri Feb 16, 2007 4:08 am
by ArndW
What does your function do for the ELSE part of the OPENPATH?

Else statement

Posted: Fri Feb 16, 2007 4:42 am
by nibble
That's the DSRMessage function call.

Chris.
ArndW wrote:What does your function do for the ELSE part of the OPENPATH?

Error located

Posted: Fri Feb 16, 2007 4:58 am
by nibble
Seems that the problem is when the file is in cache.

If the file is in cache, in other words if this command returns true:
Locate HashTable in FilesOpened Setting POS Then

Then this section fails:
Read Rec From FileHandles(POS), Keyfield Then

With the error:
Improper data type

Why ?

Chris.
ArndW wrote:What does your function do for the ELSE part of the OPENPATH?

Posted: Fri Feb 16, 2007 5:27 am
by ArndW
Print out the value when you get the error - that might give you a clue as to what is happening. It won't print if it is a proper file pointer, but the error message you are getting already tells us that it isn't correct.