Page 1 of 1

Trim Function

Posted: Thu Jun 07, 2007 7:36 pm
by cosec
For what data types should i use the Trim function ?


I read data from a sequential file and load to a target Db2 table...whether i use a trim function for a timestamp or not I get the desired results...but for a character type if i dont use a trim function i have errors...

Posted: Thu Jun 07, 2007 7:43 pm
by ArndW
DataStage server doesn't care about data types. The trim function can be used on string or numeric contents, i.e. you can TRIM("123",'2','A') to remove all 2's from a number.
What kind of a TRIM() call are you using and what do you wish to do with the data?

Posted: Fri Jun 08, 2007 1:01 am
by cosec
There are a few columns in the Sequential File that are Null but when loading to the target DB2 table I get a waring ssaying that the column had to be trancated or datastage cannot convert string " " .....

To avoid this I use the function Trim(Column Name).


ArndW wrote:DataStage server doesn't care about data types. The trim function can be used on string or numeric contents, i.e. you can TRIM("123",'2','A') to remove all 2's from a number.
What kind of a TRIM() call are you using and what do you wish to do with the data?

Posted: Fri Jun 08, 2007 1:25 am
by ArndW
If you are using a simple TRIM you will be removing all leading, trailing and duplicate spaces as well at tabs from the string. This is not the same thing as a null. I recall a setting in PX for Oracle where a string of spaces can be treated as null, but as far as I recall that doesn't happen in server and with DB2.

What might be happening is that your input value is longer than what the Database column is declared as, and the TRIM() call removes the blanks and lets the string fit.