Substring Problem

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
umapathi
Participant
Posts: 5
Joined: Thu Jan 12, 2006 10:59 am
Location: India

Substring Problem

Post by umapathi »

Hi DS Gurus,

im getting the source data from the sybase as

ODVAdsti_20060913.csv
TRANSdsti_Trn_20060913.csv like that...
now i want the output like

ODVAdsti
TRANSdsti_Trn
i dont want _20060913.csv

i have to implement the logic in Transformation

i tried Field function n substring functions,but not succeed...
So please help me Gurus

Thanks in advance
Umapathy reddy
OttMAdpttch
Charter Member
Charter Member
Posts: 6
Joined: Thu Mar 27, 2003 1:55 pm
Contact:

Post by OttMAdpttch »

I can think of a couple of ways to accomplish your string extraction:

1) If you know that your data will always have the "_20060913.csv" at the end, you can simply do a the following in your derivation:

link.columnname[1,Len(link.columnname)-13]

This approach will always work no matter which format of the data you're receiving. It can also be easily incorporated into a Datastage transform so that it can be used over and over again.

2) You can also use a couple of stage variables as follows:

Variable Name=Derivation
-----------------------------------------------------------
DelCount=Count(link.columnname,"_")
WantedData=Oconv(link.columnname,"G0_":DelCount)

If you need to use this logic in several jobs it can easily be put into a Datastage routine.

Hope this helps!

Mark
Mark Ott
DataStage Architect
Adept Technologies, Inc.
umapathi
Participant
Posts: 5
Joined: Thu Jan 12, 2006 10:59 am
Location: India

Post by umapathi »

Hi, first one working fine and im getting the desired output
link.columnname[1,Len(link.columnname)-13]
Thanks

but second solution in stage variable showing the error
that VARIABLE 'Oconv' not defined

could u explain what is ment by ' Go_' in the logic,what it actually do?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Oconv() is not available in parallel Transformer stages. You can learn about the "G" (group) conversion in online help for Oconv(), but it won't help you.
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