Page 1 of 1

Substring Problem

Posted: Fri Sep 15, 2006 6:43 am
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

Posted: Fri Sep 15, 2006 7:17 am
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

Posted: Fri Sep 15, 2006 8:05 am
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?

Posted: Fri Sep 15, 2006 5:08 pm
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.