Page 1 of 1

Routine To Create a HASHFILE

Posted: Wed Aug 16, 2006 4:46 am
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

Re: Routine To Create a HASHFILE

Posted: Wed Aug 16, 2006 4:56 am
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

Re: Routine To Create a HASHFILE

Posted: Wed Aug 16, 2006 4:59 am
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

Posted: Wed Aug 16, 2006 5:01 am
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) :?

Posted: Wed Aug 16, 2006 6:35 am
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".

Posted: Wed Aug 16, 2006 6:54 am
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

Posted: Wed Aug 16, 2006 7:01 am
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.

Posted: Wed Aug 16, 2006 7:50 am
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:

Posted: Wed Aug 16, 2006 9:34 am
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.