Unable to trim leading zeroes using trim()

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

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

Post by ArndW »

I just wrote a 60-second PX job. Starts with a row generator that generates 100 rows with just one column called "Test" of type VarChar(32). The "edit row" sets the values to cycle between "00001" and "00000002". The transform does a simple "TRIM(DSLink2.Test,'0','L')" and the output goes to a PEEK stage. The job runs and the peek output shows that the leading '0' characters have been trimmed.

Are you using NLS in your project and could your zeroes be another glyph in the character space? You could add a SEQ(Test[1,1]) to your output to see if the returned value is 32 as expected.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Umm... 32 is Seq(" "), not Seq("0") :oops:
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 »

Yep - thanks for the correction.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hmm.. I am not quite sure, NLS is going to be an issue. because Trim function is used with '0' and not with the character which returns 48 [Seq('0') = 48] :?

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

Post by ArndW »

Kumar - I don't understand what your post means. The point of my question was to make sure that the string contains a "0" character as we expect it - namely one which has ascii value of 48. If the string contains another glyph then then you would need to change the TRIM function to remove that. All the people here who have tested the TRIM() function have done so successfully, so the attempt is to look for some other explanation. My NLS conjecture is a stab in the dark.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

ArndW wrote:Kumar - I don't understand what your post means. The point of my question was to make sure that the string contains a "0" character as we expect it - namely one which has ascii value of 48. If the string contains another glyph then then you would need to change the TRIM function to remove that. All the people here who have tested the
TRIM() function have done so successfully, so the attempt is to look for some other explanation. My NLS conjecture is a stab in the dark.
Poster was not able to perform Trim('0001','0','L').
If seq('0') was not equal to 48, then value (0) in the '0001' should not also be equal to 48. ie., both underlying unicode should be equal (atlest with respect to datastage). For example, if seq('0') returns 50 unexpectedly, the '0' in '0001' should also return the same. And so, should trim. So i was under the impression that it could be of some other issue. Sorry if if i got it wrongly :roll:

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

Post by ArndW »

Kumar - I see what you mean; I went back and saw that the poster did use a constant text, not data. So it really ought to have worked, regardless of any NLS setting! :shock:
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Post by alisoviejo »

I had a smilar issue and had to use ltrim inthe Oracle stage (Source) !
ALISO
jmessiha
Participant
Posts: 21
Joined: Fri Nov 12, 2004 9:48 am

Post by jmessiha »

Yeah, what a pain. Thats why I ended up using the oconvert, trimf, oconvert again. I still don't know why the Trim is not working as described.
alisoviejo wrote:I had a smilar issue and had to use ltrim inthe Oracle stage (Source) !
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Have you reported to Ascential as BUG. Open a case with Ascential and they might be able to sort out this issue.
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi,

Iam facing a fatal error when Iam trimming white spaces. I have source file text file with material char(7) as a columm and Iam having a OSP in DB2 table with Varchar(7) as a key. Iam looking with Material to OSP . I used functions to trim whitespaces after material and I also had two Leading 00 before material.

Ex 00S0003X

I used TrimLeadingTrailing(Frm_src.Material) and I also tried with StripWhitespace(frm_src.Material). Iam getting an error showing....


main_program: Syntax error: Error in "lookup" operator: Error in input redirection: Error in input parameters: Error in view adapter: Error in binding: Expected '=', got: ")", line 43
Expected ';' or ']', got: "=", line 43; text: "=", line 43 [view()
Expected option or identifier, got: ")", line 44; text: [view()=OSP;


2. I have another doubt . In lookup stage. for Lookup key MANDT. Iam assigning Key expression as job parameter can I give like that

for ex :

lkuptable

Keyexpression . colummname
bbbb(from job parameter) . mandt



Thanks,
Somaraju
somaraju
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please don't hijack threads. Neither of your questions relates to trimming leading zeroes from strings in parallel jobs. Please start a separate thread for each, to assist future searchers.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply