Routine To Create a HASHFILE

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ragugct
Participant
Posts: 1
Joined: Wed Jul 19, 2006 6:39 am

Routine To Create a HASHFILE

Post by ragugct »

Hi,

I need to call a Routine in the Before-Job Subroutine to create the hashfile,if it does not exists in the specified path.If exists then dont need to do any thing.

Planning to pass hashfilename as a parameters to the routine.

Only one column need to be in the hashfile with data type Char(100).

need your help on this.

Thanks in Advance
kdpuram
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

Re: Routine To Create a HASHFILE

Post by prabu »

ragugct wrote:Hi,

I need to call a Routine in the Before-Job Subroutine to create the hashfile,if it does not exists in the specified path.If exists then dont need to do any thing.

Planning to pass hashfilename as a parameters to the routine.

Only one column need to be in the hashfile with data type Char(100).

need your help on this.

Thanks in Advance
please try detele file and create option which is already available
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

Re: Routine To Create a HASHFILE

Post by prabu »

ragugct wrote:Hi,

I need to call a Routine in the Before-Job Subroutine to create the hashfile,if it does not exists in the specified path.If exists then dont need to do any thing.

Planning to pass hashfilename as a parameters to the routine.

Only one column need to be in the hashfile with data type Char(100).

need your help on this.

Thanks in Advance
please try detele file and create option which is already available
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

Do search your hashed file in VOC using

Code: Select all

SELECT COUNT(*) FROM VOC WHERE TYPE='F' and NAME='Hashedfilename'
if it returns 1 then the Hasehd file is existing else create one using the

Code: Select all

CREATE.FILE filename DYNAMIC
may be (using Create table command also) :?
Success consists of getting up just one more time than you fall.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

ragugct wrote:Hi,

I need to call a Routine in the Before-Job Subroutine to create the hashfile,if it does not exists in the specified path.If exists then dont need to do any thing.

Planning to pass hashfilename as a parameters to the routine.

Only one column need to be in the hashfile with data type Char(100).

need your help on this.

Thanks in Advance
Welcome aboard. :D

Your initial premise ("I need to create a Routine") is false. The Hashed File stage, as others have pointed out, contains all the functionality you require.

I would also counsel against the use of job parameters for file/table names, as it interferes with good metadata management.

To what purpose would you put a hashed file containing a single Char(100) column - which must therefore be the "Key" column? It would not be particularly efficient for lookup - we tend to use trimmed VarChar keys for hashed file lookups. If it's just for storage, why not use a Sequential file, which is much faster to write to?

By the way, it's "hashed" file, not "hash" file or "hashfile".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Luciana
Participant
Posts: 60
Joined: Fri Jun 10, 2005 7:22 am
Location: Brasil

Post by Luciana »

To create a hash in a specific directory, execute the command:
mkdbfile path/HashFileName 30 1 4 20 50 80 1628

or create a routine:

Code: Select all

Call DSExecute("UNIX","ls ":PathHsh:"HashName", Output, SystemReturnCode)

If SystemReturnCode <> 0 Then
    commandUV = "mkdbfile ":PathHsh:"HashName 30 1 4 20 50 80 1628"
    Call DSExecute("UNIX", "cd ../../DSEngine/bin;":commandUV, Output, SystemReturnCode)
    Ans = 'HashFile create with success'
End
Else 
   Ans = 'HashFile existent'
End
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't understand why one would "need" to do this. :?

Any job that populates the hashed file will automatically create it if it doesn't exist. If the first usage of this hashed file is as a lookup, there is a simple way in the GUI to make sure it gets created if it doesn't already exist - feed it from a transformer (with the proper metadata) with the constraint set to @FALSE.

If you need this for some other reason, let us know. Best to not create a routine to do something that the GUI can already do for you, IMHO. For example, a routine to create a 64bit hashed file would be something that falls into that class.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Luciana
Participant
Posts: 60
Joined: Fri Jun 10, 2005 7:22 am
Location: Brasil

Post by Luciana »

Hi Craig Hulett

I have a job that makes a lookup in the hash before creating it. The hash is created in this job, then I needed to execute the command mkdbfile. I didn't get to configure in the GUI. Can you explain better as configuring?

Thank you :lol:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Drop a Transformer next to the Reference Hashed file and link them together. Add a stage variable so the compiler won't complain. Set the constraint to @FALSE so no rows go down the link, as the mere fact it is there will open the hashed file. Make sure your metadata is correct in the link, but the derivations don't matter as they won't be used. I generally set them all to @NULL to drive home the point. :wink:

This will run before the main flow and create the hashed file if needed. You can also use it to clear or drop/recreate between runs if you need to do that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply