Page 1 of 1

Get Max Key From Hashfile

Posted: Tue Dec 13, 2005 9:33 pm
by martin
Hi Guys,

I have a design, which pulls Max SUK from Hashfile, and passes to Transformation stage to generate Next Key. Now I want to get rid of these extra stages and processing time, and replace with ROUTINE which can read Max SUK from Hashfile created out Project Area.

If any can help me with Routine code, I would really appreciate.

Thanks
Martin

Posted: Tue Dec 13, 2005 10:09 pm
by ray.wurlod

Code: Select all

Trans("hashedfilename", "keyvalue", 1, "X")
Read about this function in DataStage BASIC manual. You may need to add Trans() to DSParams file if you don't like the red colour.

Posted: Wed Dec 14, 2005 6:38 am
by martin
Hi Ray,

Thanks for the reply,I will try and let you know.

Rg
Martin

Posted: Wed Dec 14, 2005 8:23 am
by martin
Hi Ray,

I tried your code

Code: Select all

TRANS("/Ascential/Datastage/DEV/Ha_RequestDim', "REQ_ID", 1, "X")
I got error
DataStage Job 85 Phantom 31381
Program "JOB.1638071665.DT.1386332505.TRANS1": Line 51, Unable to open "/Ascential/Datastage/DEV/Ha_RequestDim" file.
DataStage Phantom Finished


Any Idea

Thanks
Martin

Posted: Wed Dec 14, 2005 8:40 am
by kcbland
Your hashed file is externally pathed. Consider writing a quick function that utilizes the OPENPATH statement to open the hashed file, then a READ statement to read the appropriate row from the hashed file.

Consider also changing the hashed file to a sequential file. I'm sure you are more comfortable reading a line from a text file using a grep statement.

Posted: Wed Dec 14, 2005 3:21 pm
by ray.wurlod
It must be the name of the hashed file in a Trans() function, not its pathname. You need to create a VOC pointer using SETFILE before the Trans() function will work. You would have determined this had you read the entry for Trans() in the manual.

Posted: Sat Dec 17, 2005 9:04 pm
by martin
As per Kcbalnd I am writing to Seq File and capturing Max Key value using Transformation Routine......Its working the way it has to work.

I also tried Ray method and bit confused using .

Code: Select all

TRANS ( [DICT] filename, record.ID, field#, control.code)
1. I defined SETFILE <Full Path> in before-Job Subroutine with ExecTCL.
2. Then I used TRANS function in Transformation Derivation

first step gave me error, I know I am doing mistake, Ray i would really appreciate if can help me to understand This Function.

Thanks
Martin[/code]

Posted: Sun Dec 18, 2005 2:24 am
by ray.wurlod

Code: Select all

SETFILE pathname VOCname OVERWRITING
creates an entry called VOCname in the VOC file as a pointer to the hashed file whose pathname is specified by pathname - it is the name in the VOC file that you must use in the TRANS function.

TRANS(VOCname, keyvalue, field#, code) opens the hashed file referred to by VOCname, reads the record specified by keyvalue and returns the field whose number is given as field#. The code argument is a single letter that specifies what to do if the record can't be found.