Page 1 of 1

Trim in Schema file

Posted: Tue Jul 24, 2012 7:17 am
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

Posted: Tue Jul 24, 2012 7:31 am
by chulett
So this is actually a question about Parallel jobs? You marked the Job Type as Server, hence the question.

Posted: Tue Jul 24, 2012 9:10 am
by samyamkrishna
Hi,

Sorry about that. Yes its a parallel job.

Regards,
Samyam

Posted: Tue Jul 24, 2012 10:02 am
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.

Posted: Tue Jul 24, 2012 4:25 pm
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.

Posted: Wed Jul 25, 2012 1:29 am
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.

Posted: Wed Jul 25, 2012 1:45 am
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.

Posted: Tue Jul 31, 2012 7:09 am
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.