Page 1 of 1

Hashed file key separation

Posted: Sun Oct 30, 2005 2:54 am
by snassimr
I need to get hashed value with rotine and I dont knoe exactly how keys in hashed value separated .

I try HashKey=Key1:@TM:Key2

and i isnt work .

Any ideas ?

Posted: Sun Oct 30, 2005 3:13 am
by ArndW
The separator that DataStage uses with composite hashed file keys is the @TM (text mark). So if in a DataStage job you have a composite key for Country and City and you wish to read this record from a BASIC program, you would use a key value such as 'London':@TM:'England' to get a record.

Posted: Sun Oct 30, 2005 4:45 am
by snassimr
I get error :
Result = Program "TSTGetHashValue.B": Line 5, Variable "ANS" previously undefined. Empty string used.

What does it mean ?

Posted: Sun Oct 30, 2005 5:04 am
by snassimr
Ok > I understand it . It was my mistake.

But still @TM not working . I tried all combination of @TM , Key1 or Key2

Any ideas ?

Posted: Sun Oct 30, 2005 5:35 am
by snassimr
Sorry It was my mistake

Key1:@TM:Key2 Working

Posted: Sun Oct 30, 2005 2:11 pm
by ray.wurlod
Variable names are case sensitive.

You have assigned a value to ANS, but the routine wants to return Ans.

You must use Ans throughout (because you can not change the RETURN(Ans) function).

Posted: Mon Oct 31, 2005 4:23 am
by roy
ray.wurlod wrote:Variable names are case sensitive.

You have assigned a value to ANS, but the routine wants to return Ans.

You must use Ans throughout (because you can not change the RETURN(Ans) function).
Hi,
Sorry Ray but I beg to differ regarding the must use Ans part.
There is no limit on using your own RETURN(ANS) as long as the ANS variable was assigned a value (or using any other variable/constant in a RETURN(x) command).

I do agree that this was not what the writer intended and should have used Ans.

For clarity,readability and maintainability I recomend using the standard Ans variable for returned value from routines.

As Ray said DS Basic is case sensitive.
It also demands that any use of variables not being assigned must be previously declared or assigned a value.

Posted: Mon Oct 31, 2005 1:52 pm
by ray.wurlod
If you rely on the generated RETURN(Ans) function, which lives in a little greyed-out area at the bottom of the Routine, you can't change it.

Roy is correct in that you can make it redundant by preceding it with your own. However, the problem as originally posted was that ANS was not being assigned a value. It was based on this error message that I posted my solution.