Trim in Schema file

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
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Trim in Schema file

Post by samyamkrishna »

Hi,

I am trying to trim few of the varchar columns.
I am using a generic job which uses a schma file to load from the file to the database.

Is there way i can use a trim function on the varchar columns.

I saw few of the posts which said this is not possible in RCP.

Want to get any idea on how to do it.

REgards,
Samyam
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So this is actually a question about Parallel jobs? You marked the Job Type as Server, hence the question.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Hi,

Sorry about that. Yes its a parallel job.

Regards,
Samyam
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The modify stage can do this, in a manner. While it won't select all string columns from a schema, if you have a parameter called "ColumnName" with the name of the string column to trim, then the modify action of
"#ColumnName#=trim(#ColumnName#)" will do what you want for one column.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The function in a Modify stage is string_trim() and requires that you specify which character you want trimmed and from where.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Sorry, I mis-pasted the function, it is as Ray notes, "string_trim". I took a quick look at what might be done that could apply across a whole schema but don't think that there is any such functionality.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You could perform the import (read) using a single VarChar column (which could be trimmed in a Modify stage) and then perform the parsing in a Column Import stage (which can use a schema file). An added benefit is that your parsing can be performed in parallel mode.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Thanks a lot Ray And ArndW

I used this as a parameter and passed the value

POST_CODE:string[max=8] = string_trim[" ",end,begin] (POST_CODE)

Works brilliantly.
Post Reply