Trim Function in Modify Stage

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

Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Trim Function in Modify Stage

Post by Nageshsunkoji »

Hi Folks,

In One of Ascential Provide Document I read about the following function in the Modify stage :

stringField=string_trim[character, direction, justify] (string)

In the document they wrote that the above function will trim the Leading or Trailing charcters from the String. But , when i tried above function i am getting Fatal error. can any body workaround this function, if it is true please correct me the synatx and function.

Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Nagesh,

could you show us what you actually entered in the modify stage? The function should work, I can recall having tried it in the past. Also you might tell us the data type and contents as well as the actual error message you received - is it a compile or a runtime error?
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi Arnd,

Thank you for your reply.

I tried with the below function and i got the result now.

Empname= string_trim['0', begin, end](Empname)

Previously I tried with another round means i tried like this

Empname= string_trim['0', begin, end](Nagesh)

My undersatnding was not proper at that time, now its Ok.

Now I have one more query, is it possible to trim Leading and tariling spaces by using modify stage ? I tried by using above function, but its not trimming spaces.

Your inputs are more appreciate.

Thanks and Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi All,

I tried to remove the Leading spaces from the string by using the following function:

Empname= string_trim[" ", begin](Empname)

I succeeded by trimming Leading spaces.

But i failed to remove tariler spaces by using following function :

Empname= string_trim[" ", end](Empname).

Could any body try out this fuction, Please let me know abt this function some more inputs.

Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
rgandra
Premium Member
Premium Member
Posts: 49
Joined: Mon Aug 02, 2004 9:31 am
Contact:

Post by rgandra »

Hi All,

I used following function to remove Leading and Trailing spaces.

Empname= string_trim[" "](Empname)


I think this is what you are trying to know.

Thanks,
rgandra
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi Rgandra,

I tried out the function mentioned by you

Empname= string_trim[" "](Empname)

But i didn't get the proper result.

Its not removing Leading and Trailing spaces.

Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Try just the following:

Empname= string_trim(Empname)

It should trim spaces by default.
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi vmcburney

I tried the function mentioned by you

Empname= string_trim(Empname)

still i am not getting proper result. Its not removing the Trailing and leading spaces.

Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is EmpName a string[nn] (Char) or a string[max=nn] (VarChar) data type?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

ray.wurlod wrote:Is EmpName a string[nn] (Char) or a string[max=nn] (VarChar) data type?
Hi Ray,

My attribute EmpName is Char Data Type and I am generating the spaces in the Empname data by using Row Generator.

Thanks & Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Try defining the output field as varchar, you might be putting it into a CHAR field.

NewEmpname varchar(255)=string_trim(Empname)

Now I remember why I never use the Modify stage.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Don't forget the colon.
NewEmpname: nullable varchar(255)=string_trim(Empname)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ajith
Participant
Posts: 86
Joined: Thu Nov 10, 2005 11:10 pm

Post by ajith »

ray.wurlod wrote:Don't forget the colon.
NewEmpname: nullable varchar(255)=string_trim(Empname)
When you use "nullable varchar" instead of "nullable string" it gives out an error.Error parsing modify adapter: Error in binding: Could not find type: "varchar"


I searched all the threads tried all the functions, but I did not see anything like trimleadingtrailing. I dont think that can be done in modify stage.

Anybody any new idea????
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

My error. Should have been:

Code: Select all

NewEmpname: nullable string[max=255]=string_trim[" "](Empname)
The default trimmable character is APT_STRING_PADCHAR which, unless you've changed it, is Char(0), not space.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ajith
Participant
Posts: 86
Joined: Thu Nov 10, 2005 11:10 pm

Post by ajith »

ray.wurlod wrote:My error. Should have been:

Code: Select all

NewEmpname: nullable string[max=255]=string_trim[" "](Empname)
The default trimmable character is APT_STRING_PADCHAR ...


I tried that too,

It is trimming only the trailing spaces not the leading ones.

I seriously don't know what to do now, I have to do Trimming on 3 source feeds. I hate modify stage, it allows me to do nothing. Dont tell me the only way forward is adding 3 transformer stages.
Post Reply