Trim Function

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Trim Function

Post 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...
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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?
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post 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?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
Post Reply