DB2 equivalent of substr()

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
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

DB2 equivalent of substr()

Post by opdas »

Hi,
We have source as flat file and have to load another flat file and have to transform a field which would be picking a substring.

Its like picking a substring in a DB2 table using function substr(column,3,5) , which would give be a substring from character 3 to character 5 of the string.

Do we have a datastage equivalent for this ??
Om Prakash


"There are things that are known, and there are things that are unknown, and in between there are doors"
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I know in server you do
Incolumn[3,5]. Not sure if that works in a PX transformer. Someone else here needs to confirm that.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

In parallel do Columnname[3,5]

should work
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Krazykoolrohit wrote:In parallel do Columnname[3,5]

should work
The OP needs substring from character 3 to character 5.

Code: Select all

Columnname[3,2] 
Thanks
Sam
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Oh. i read other syntaxes and thought he needs 5 characters from 3rd position. my mistake.. :oops:
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Re: DB2 equivalent of substr()

Post by DSguru2B »

opdas wrote:Its like picking a substring in a DB2 table using function substr(column,3,5) , which would give be a substring from character 3 to character 5 of the string.
Actually the OP contradicts his statement. We all just looked at his substr() example
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In a Modify stage numbers are zero-based, so the third character is number 2 and the required function is either substring[2,5](field) or substring[2,3](field) as the other issue is resolved.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Post by opdas »

Thank you everybody ......
Om Prakash


"There are things that are known, and there are things that are unknown, and in between there are doors"
dsdesigner
Participant
Posts: 34
Joined: Thu Jul 29, 2004 1:03 pm

Post by dsdesigner »

In a parallel transformer right(left(column_name,5),2)??

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

Post by ray.wurlod »

Cumbersome. Parallel Transformer supports the [,] syntax. Choose Substring from the operator menu in the Expression Editor.
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