Extracting from a hash file in numeric order.

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
Baldo
Premium Member
Premium Member
Posts: 10
Joined: Tue Jun 24, 2003 11:59 pm
Location: Sydney, Australia

Extracting from a hash file in numeric order.

Post by Baldo »

Hi,

I am writing a custom Server Routine to read out of a hash file. The only problem is that the key is a number. I have tried:

Code: Select all

SSELECT FILENAME TO X
That returns data sorted alphabetically (1, 10, 2, 3, etc).

I have done searches on previous topics and found nothing like this (lots on sorting, but none for numeric keys). Ideally, I would like to avoid having to use a separate job with a sort stage to a sequential file (which is the only way I know) as this is a transform routine to be reused.

Thanks,

Chris.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Code: Select all

EXECUTE \SSELECT yourhashfile BY yourkeycolumn  FMT "12R"\
Your primary key column must be showing as a left justified field in the hash file dictionary. Override this format using the FMT keyword when you execute the select. You cannot use a BASIC select, you must switch to an EXECUTE or PERFORM.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

If you want to see a good online help manual, check out:

http://members.aol.com/_ht_a/mbtexts/31.html

In fact, there's a wealth of information here for anyone who wants to dive into Universe BASIC full time.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Baldo
Premium Member
Premium Member
Posts: 10
Joined: Tue Jun 24, 2003 11:59 pm
Location: Sydney, Australia

Post by Baldo »

Hi Kenneth,

Thanks for your reply. It compiled alright, but when I tested it, I got the following error:

Code: Select all

Retrieve: syntax error.  Unexpected sentence without filename.  Token was "".
          Scanned command was SSELECT 'LOG' BY '@ID' FMT '12R' 
Also, can I select into a numbered select list in an EXECUTE?

Thanks,

Chris.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

It would only help to have your exact command.

I'm guessing you've got single quotes all over the place and that's wrong.

Try:

Code: Select all

EXECUTE \SSELECT LOG BY @ID FMT "12R"\
Is it imperative that you select to a list? If so, just add the appropriate keywords.

Please visit here, as it has all of the answers:

http://hometown.aol.com/mbtpublish/1.html
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Baldo
Premium Member
Premium Member
Posts: 10
Joined: Tue Jun 24, 2003 11:59 pm
Location: Sydney, Australia

Post by Baldo »

Hi Kenneth,

I am looking at the web pages you posted the address of now. But so you know, I did actually have it exactly as you put it in (with no quotes - apart from those you specify). It just seems to parse it that way.

I will write back if I still can't do it.

Thanks,

Chris.
Baldo
Premium Member
Premium Member
Posts: 10
Joined: Tue Jun 24, 2003 11:59 pm
Location: Sydney, Australia

Post by Baldo »

Hi,

I am still having no luck. Any advice would be appreciated.

Thanks,

Chris.
Baldo
Premium Member
Premium Member
Posts: 10
Joined: Tue Jun 24, 2003 11:59 pm
Location: Sydney, Australia

Post by Baldo »

Got it!

I assumed that the 'yourhashfile' part of your code refered to a file variable. I have found that it refered to the actual name (a mistake on my part - but that was how it worked in the select without the execute). I had an OPEN statement above and assumed that this operated on the open hashfile referenced by the LOG file var.

Thanks for your help.

Regards,

Chris.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you want the SSELECT filevariable statement to perform a numeric sort of the keys, change the definition of @ID in the file dictionary so that it is right-justified rather than left justified. For example:

Code: Select all

UPDATE DICT hashedfilename SET FORMAT = '10R' WHERE @ID = '@ID';
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply