Page 1 of 1

RTRIM(LTRIM()) help

Posted: Wed Sep 22, 2004 8:36 am
by him121
hi..
guys..
we have more than 100 columns in Source DRS Stage...
in derivation we want to write RTRIM(LTRIM()) for all the CHAR Columns..
this is taking lot of time to write manually..

is there any shortcut method to this.

thanx in advance

Posted: Wed Sep 22, 2004 8:58 am
by chulett
Not really. Your RTRIM/LTRIM syntax is database syntax, you could replace it with just Trim() in the derivation and accomplish the same thing.

If you are good with something like Perl or Awk (or perhaps a good editor), you may be able to export your job to .dsx or .xml format and make the substitutions that way. Then just import it back into the project and recompile.

Posted: Wed Sep 22, 2004 9:05 am
by kcbland
The 7.1 Designer has a macro (right click on a column) to propagate a common function, like TRIM, to all derivations in a link. Can save a lot of time, check it out.

Posted: Wed Sep 22, 2004 9:09 am
by chulett
That's true - forgot about that one. :oops: Open up your transformer and right-click in the derivation. You'll find something called Derivation Substitution that should get you what you need.

Available in 7.0 and up.

Performance

Posted: Wed Sep 22, 2004 4:03 pm
by ray.wurlod
The correct function names are TRIMB and TRIMF rather than RTRIM and LTRIM.

But you can also use the extended form of TRIM, where the third argument of "B" removes leading and trailing. For example, TRIM(TheString, " ", "B") removes leading and trailing spaces.

One function is cheaper to execute than two. When you're processing milions of rows, every little gain helps.