Issue with trailing spaces

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
ds_is_fun
Premium Member
Premium Member
Posts: 194
Joined: Fri Jan 07, 2005 12:00 pm

Issue with trailing spaces

Post by ds_is_fun »

I earlier posted a Q with how to get rid of trailing weird characters. The issue was solved after getting a response here on DSX asking to change settings in the DS Admin, changing the variable APT_STRING_PADCHAR to space. Thanks gh_amitava.
Now after the change Im getting trailing spaces that I can't rid off by using any of the DS functions (TRIM, TRIMB,CompactWhiteSpace, TrimWhiteSpace) for the CHAR type field.
Pl. suggest. THanks!
ds_is_fun
Premium Member
Premium Member
Posts: 194
Joined: Fri Jan 07, 2005 12:00 pm

Post by ds_is_fun »

Im answering to my own post,
The problem seemed in PX 7.5.1 itself.
The fields with the CHAR datatype and that had string values got padded with SPACES. Ironically, number values din't get pad with SPACES in the same CHAR field type. Once, I changed all the datatypes to VARCHAR I tweaked the problem. Looks like PX 7.5.1 behaves differently in these type of cases. But I still don't have the answer to the problem although I tweaked it.
Thanks to myself!
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
This is more of a C++ issue.
when you define a string of 50 characters you'll get 50 characters even if you actually only use 10.
(I think DS should usually puts a binary zero or the pad char for the reminder space, but I'm not sure.)
now if you don't initialize the entire 50 characters you'll most likely get 10 characters then string termination '\0' and the rest will be garbage data.
So if some one put a unseen charcter string in the pad character you might get what you had.
You can now see what putting a space, as you did, resulted in.

A you found out using varchar usually prevents such issues, tough you might need the occasion conversion/transformation applied.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Post Reply