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
lsnovick
Participant
Posts: 80
Joined: Fri May 25, 2007 7:24 am
Location: Troy

Trim function

Post by lsnovick »

I have a field that I am bringing in from a flat file. I am using the TrimB and TrimF function but when I do a length in the database, it includes a place for the space/blank. How can I make it only include real data and not spaces?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What database and how is it defined there?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

What datatype it is?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

View the file in the text editor and check whether you have any special characters other than space.
lsnovick
Participant
Posts: 80
Joined: Fri May 25, 2007 7:24 am
Location: Troy

Post by lsnovick »

It is Varchar. I have tried all the TRIM options without it working.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

How about giving some required details like source field and source system.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
lsnovick
Participant
Posts: 80
Joined: Fri May 25, 2007 7:24 am
Location: Troy

Post by lsnovick »

Source field: Varchar. Target field: Varchar. Moving csv UNIX file to Oracle database.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Just check if there is any defaults value been inserted in during target stage. What is the job design. What is the stage right after transformer(where Trim function is used)?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Post by TJX Companies »

I had the same problem in one of my jobs. I resolved it initially in a roundabout way by calculating the length by using Index function on first space to get the length of the string and then moving (1, length) to the output field.

Later I found that if you define your field as VarChar in all the stages TRIM works properly. In one of my stages inbetween I had the field definition of Char that cuased the issue. Please check whether you definied the field as VarChar in all stages. If you still have the issue try using my first roundabout method. Good Luck.

Aruna.
thamark
Premium Member
Premium Member
Posts: 43
Joined: Thu Jan 29, 2004 12:12 am
Location: US

Re: Trim function

Post by thamark »

lsnovick wrote:I have a field that I am bringing in from a flat file. I am using the TrimB and TrimF function but when I do a length in the database, it includes a place for the space/blank. How can I make it only include real data and not spaces?
Check the flat file to see, if you are getting spaces or un printable characters. Remeber TRIM will not consider these un printable characters for trimming.

You could check this by opening the file in unix, which will not show complete line or you can download the file to your local machine and open the file in texpad to see, if you have these characters in it...
Hmm i will fill this when ever i get one
Post Reply