Sequence Generation

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
asnagaraj
Participant
Posts: 26
Joined: Wed Jun 25, 2003 12:41 am

Sequence Generation

Post by asnagaraj »

I am dealing with files.

I have an input sequential file that has data like
1,AAA
4,DDD
2,BBB
3,CCC
and so on
my requirement is to add a new incoming data like EEE into this file as
5,EEE
that is i want to find the max of the input key (here number) and add 1 to it forming the new key and then appending the row with some other column from other file.




Programmer Analyst,
Cognizant,
Chennai.
raviyn
Participant
Posts: 57
Joined: Mon Dec 16, 2002 6:03 am

Post by raviyn »

you can use the keymgtgetnextvalue or KeyMgtGetNextValueConcurrent utility.This writes nothing but the last value for a given string in SDKSequences file.U can see the code ,thus remembering next which value to print which is nothing but say 5 .....[:)].HTH
raviyn
Participant
Posts: 57
Joined: Mon Dec 16, 2002 6:03 am

Post by raviyn »

you can use the keymgtgetnextvalue or KeyMgtGetNextValueConcurrent utility.This writes nothing but the last value for a given string in SDKSequences file.U can see the code ,thus remembering next which value to print which is nothing but say 5 .....[:)].HTH
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is your target? There are many options available, depending on what your target it. For example, does your target support a SERIAL data type, or a SEQUENCE that can be defined on a key column? If so, DataStage can make use of these.


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
asnagaraj
Participant
Posts: 26
Joined: Wed Jun 25, 2003 12:41 am

Post by asnagaraj »

My target is currently a sequential file only..but its enough too always i can load data from my seq. file to Hash or databases.

Also if u can explain me clearly abt the KeyMgmt routines..iam not much clear with their usage.

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

Post by ray.wurlod »

Take a look at the source code for the key management routines (in the Routines branch, under SDK). That code, along with the long description on the General tab, will provide you with all the information you require.


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
asnagaraj
Participant
Posts: 26
Joined: Wed Jun 25, 2003 12:41 am

Post by asnagaraj »

sorry guys if my query was diverting, but my requirement is purely not a sequence generation. i already have an input sequential file and wanna add one more record to it with the new key being generated by adding 1 to the max key already available in the file.i cannot be more clearer than this.

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

Post by ray.wurlod »

Assuming the key values are in sorted order in the text file, you could use tail -1 filename to obtain the last line, get the key value out of this to initialise a stage variable, and increment the stage variable as each line is processed.
Post Reply