Page 1 of 1

Sequence Generation

Posted: Mon Mar 03, 2003 3:22 am
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.

Posted: Mon Mar 03, 2003 3:29 am
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

Posted: Mon Mar 03, 2003 4:25 am
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

Posted: Mon Mar 03, 2003 4:40 am
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

Posted: Mon Mar 03, 2003 5:32 am
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.

Posted: Mon Mar 03, 2003 11:50 am
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

Posted: Mon Mar 03, 2003 9:58 pm
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.

Posted: Tue Mar 04, 2003 5:44 am
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.