Syntax for substring

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Syntax for substring

Post by ambasta »

Can anyone please help me getting syntax for substring.
My requirement is...
I have a column having data like 0000000000012345678(length is 19)and i want to populate it to the target side as 00000012345678(length is 14).how to do it??
is there any inbuilt function in parallel job???


Regards,
ambasta
ambasta
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes, you can use the syntax of In.ColumnName[6,14] or even a RIGHT(In.ColumnName,14).
Last edited by ArndW on Tue Oct 03, 2006 6:01 am, edited 1 time in total.
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

Is the length of your input is always fixed i.e. all 19 chars will have value?
If yes, then just say InCol[6,14] and it should work.
Regards,
S. Kirtikumar.
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Thanx a lot your kind suggessions,but,unfortunately these functions are not working for me.Somehow i made this work,but i don't know how it is working.
Ex..if i need last 14 element out of 19 then IN.Col[16,14] is working and if i need last 12 element out of 19 then InCol[18,12] is working.
Can anyone help me???
ambasta
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Thanx a lot your kind suggessions,but,unfortunately these functions are not working for me.Somehow i made this work,but i don't know how it is working.
Ex..if i need last 14 element out of 19 then IN.Col[16,14] is working and if i need last 12 element out of 19 then InCol[18,12] is working.
Can anyone help me???
ambasta
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Thanx a lot for your kind suggessions,but,unfortunately these functions are not working for me.Somehow i made this work,but i don't know how it is working.
Ex..if i need last 14 element out of 19 then IN.Col[16,14] is working and if i need last 12 element out of 19 then InCol[18,12] is working.
Can anyone help me???
ambasta
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Thanx a lot for your kind suggessions,but,unfortunately these functions are not working for me.Somehow i made this work,but i don't know how it is working.
Ex..if i need last 14 element out of 19 then IN.Col[16,14] is working and if i need last 12 element out of 19 then InCol[18,12] is working.
Can anyone help me???
ambasta
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

Looks like you need to check the datatype and length of the input field you are trying to substring.

The behaviour you describe suggests the field is 30 characters long.

Run the job with $OSH_PRINT_SCHEMAS set to true and examine what the datatypes really are.
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

spot the mistake... that would 29 characters long
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Actually the incoming column's dataype is Decimal(19,4) and target datatype is char(15) as i am writing to file.My requirement is to multiply input column by 10,000 and then populate it to fixed width file.this is the actual data that i am getting 000000000000019.0000 and my requirement is to populate it as 000000000190000
ambasta
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Perform the calculation, then convert the decimal number to a string. You can use the Right() function to extract the relevant number of characters from the right-hand end.
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