Trailing end character

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
cyclogenisis
Premium Member
Premium Member
Posts: 48
Joined: Wed Jan 07, 2015 3:30 pm

Trailing end character

Post by cyclogenisis »

Setup:

Pulling in CSV to sequential file, record delim is UNIX. When I view data with the seq definition everything looks good. I then put the data through into a transformer stage which look at the last column of the sequential file. I used the following function in a stage variable:

If Trim(mylink.col1) = "-" Then "0.00" Else Convert('%','',mylink.col1)

Then use the stage variable directly into a column derivation.

After this for some reason the output of the transformer this column contains a space at the end. I tried to remove this space by trimming it but it still remains. I have no idea why this is happening. There is no spaces at the end of this column coming into the transformer stage ( I checked through a peek stage). This is causing issues when I then use a StringtoDecimal function after because it's seeing this trailing character. any help here would be appreciated.

Edit: I can also confirm even if I map the input column directly to an output column I am still getting a trailing space at the end. This shouldn't be happening I don't see the character existing at all in the sequential file view data, or directly from a peak stage from the sequential file. Also when I LEN function on this column it is saying there is an extra character... but I can't trim it and it appears to be a space.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Just a guess - is your data type set to Char? If so, then it will pad the value up to your Char limit. Maybe you would want to use Varchar data type instead.
Choose a job you love, and you will never have to work a day in your life. - Confucius
cyclogenisis
Premium Member
Premium Member
Posts: 48
Joined: Wed Jan 07, 2015 3:30 pm

Post by cyclogenisis »

It Is Varchar. Everything is set to varchar (stage var, input, output) for now just to get this portion fixed first. So, also I made a copy of the job deleted the transformer stage. Added a new one in, mapped to it did input to output and no characters were added. Once I used the conversion functions, trailing spaces started to show up again.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since the type is varchar() then if the trim() doesn't remove the character it isn't a space. Try sending "seq(Right(YourStageVar,1))" to a peek stage to see what the ASCII value of that character is.
cyclogenisis
Premium Member
Premium Member
Posts: 48
Joined: Wed Jan 07, 2015 3:30 pm

Post by cyclogenisis »

Thanks ended up using LEFT and worked.
Post Reply