Read from hashtable

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
juliyas
Participant
Posts: 14
Joined: Wed Feb 09, 2005 10:32 am

Read from hashtable

Post by juliyas »

Hi all,
i wrote routine in which i read from hashtable by :

SELECT doneFile to 1
DONE = @FALSE
Loop
Call DSLogInfo('In Loop', 'Job COntrol')
READNEXT key FROM 1 Else DONE = @TRUE
...

the readnext command read by key, but i want read 2 columns from hash where the first column is key.
How i can do it?

Thanks,
Juliya
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
when you readnext by key you get the reminder of the row returned without hte key value.
you might also want to go over openpath and related commands in your BASIC.pdf file in the docs directory under your installation directory.

you can also search this forum, there are previous posts for handling hash files here.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Juliyas,

What Roy said is not quite right, but pretty close.

The SELECT statement will put a list of all file KEYS into memory. The READNEXT statement gets the next key value from this list until the end has been reached.

With your code you need to add another line to read the contents of the record:

Code: Select all

READ InRecord FROM doneFile, key ELSE CALL DSLogFatal('Unable to read "':key:'" from input hash file','')
Now the variable InRecord will contain a string with the record contents, with each column as it is defined in the Hash File being separated by the @FM character. So if you want the 2nd column you could use

Code: Select all

InRecord<2>
.
Last edited by ArndW on Mon Apr 04, 2005 9:02 am, edited 1 time in total.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Thanks for the correction ArndW :)
Kinda hard testing and rechecking everything, I thought I remembered correctly but I guess I mixed something up there :oops:
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Roy - no problem there, you just overlooked the SELECT memory list. We've all been-there-done-that before. :P
juliyas
Participant
Posts: 14
Joined: Wed Feb 09, 2005 10:32 am

Post by juliyas »

thanks
Post Reply