Trim Function

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
Vajranath
Participant
Posts: 6
Joined: Wed Jul 26, 2006 2:33 am
Location: Bangalore

Trim Function

Post by Vajranath »

I have data in column like this

1)

1ABC
12ABC
123 ABC
in each record ABC present . only 3 letters.

i want output like
1
12
123

can any one help me in this?

2) Column records are
ABC1
ABC12
ABC123

I want output like

1
12
123

help me ..
Vajranath B K
Bangalore-INDIA
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

As per what I got from your example - in scenario one values will be appended with ABC and second prefixed with ABC.

case 1 - Use the Index first to locate the occurence of ABC and then from input extract substring starting from 1 till (value returned by Index - 1).

case 2 - Extract the substring starting from 3 till (length of input column - 3)
Regards,
S. Kirtikumar.
Vajranath
Participant
Posts: 6
Joined: Wed Jul 26, 2006 2:33 am
Location: Bangalore

howw to use substring

Post by Vajranath »

Kirtikumar wrote:As per what I got from your example - in scenario one values will be appended with ABC and second prefixed with ABC.

case 1 - Use the Index first to locate the occurence of ABC and then from input extract substring starting from 1 till (value returned by Index - 1).

case 2 - Extract the substring starting from 3 till (length of input column - 3)
Kirtikumar,
can you guide me how to use substring ?
please give one example...
Vajranath B K
Bangalore-INDIA
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hey Vajranatah,

Try out this function in Transformer stage :

Trim(Convert('ABC',' ', DSLink3.Example)).

Hi All,

This function is working and its converting multiple charcters into one specified character.

Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Nageshsunkoji wrote:Try out this function in Transformer stage :

Trim(Convert('ABC',' ', DSLink3.Example)).
This function is working and its converting multiple charcters into one specified character
That is what the TRIM function does when the option is not specified :wink:
Kris

Where's the "Any" key?-Homer Simpson
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Remember that CONVERT('ABC','',"This BCA") will return "This "; the CONVERT function works on a character-by-character basis and not on the whole string.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Actually Trim function eliminates the given string and not the conversion.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi All,

I don't know, what Miracle happened with my Datastage. The Convert function is Working for me. It's replaced the Multiple characters into one charcter. I tried by converting the 'ABC' with ' '.

I got the result without Trim function and I have used trim to remove spaces from string which are resulted due to conversion function.

Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Again you are eliminating the 'ABC' with '' opton passed. Where the possible options are 'L', 'R','B'...
Try to convert to some other characther. You can find the difference.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

kumar_s wrote:Actually Trim function eliminates the given string and not the conversion.
In the example the CONVERT is executed before any TRIM.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Inspite of repeated post, somehow I didnt noticed the CONVERT function within Trim.
Nagesh - Arnd has already explained the way how CONVERT works.
I shouldn't be wake up even after 12:30 AM. :evil:
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Vajranath
Participant
Posts: 6
Joined: Wed Jul 26, 2006 2:33 am
Location: Bangalore

Thanks

Post by Vajranath »

Nageshsunkoji wrote:Hey Vajranatah,

Try out this function in Transformer stage :

Trim(Convert('ABC',' ', DSLink3.Example)).

Hi All,

This function is working and its converting multiple charcters into one specified character.

Regards
Nagesh.
Trim(Convert('ABC',' ', DSLink3.Example)).
above function works.
Thanks for all
Vajranath B K
Bangalore-INDIA
Post Reply