remove carriage return

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
sun786
Participant
Posts: 34
Joined: Mon Feb 07, 2005 5:48 am

remove carriage return

Post by sun786 »

Hi all,

Ther is a carriage returns in the text of one of string fields in a coloumn.

Eg: PAY SLIP is the value of a field. SLIP is going to the next row as there
is a carriage retrun after PAY.

I need to remove this carriage return from the feild.

Please help.

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

Post by ray.wurlod »

Code: Select all

Convert(Char(10):Char(13),"",InLink.ColumnName)
Even though you're on UNIX, removing CR as well as LF is not a bad move, since the original source could have been a DOS file. If it wasn't then there aren't any CR characters, so there's no harm done.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
StefL
Participant
Posts: 47
Joined: Fri Feb 25, 2005 3:55 am
Location: Stockholm
Contact:

Post by StefL »

You might be able to use the CONVERT function, like I've recently done but in the 'opposite' direction (I wanted to convert comma to line feed).
Since CR is not a character you can type into a derivation field you also need to use the CHAR function and feed it with the ASCII number for CR (13).

So try writing CONVERT(Char(13),"",<in_string>) where <in_string> is the string that contains CR. I assume you just want to remove CR, hence the empty string "", else just put anything you want to replace CR with between the quotes.
sun786
Participant
Posts: 34
Joined: Mon Feb 07, 2005 5:48 am

Post by sun786 »

how abt using Ereplace function?
MaheshKumar Sugunaraj
Participant
Posts: 84
Joined: Thu Dec 04, 2003 9:55 pm

Post by MaheshKumar Sugunaraj »

Yes you could use Ereplace as well,

Ereplace(ColumnName,Char(13),"")

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

Post by ray.wurlod »

EREPLACE is less efficient than CONVERT where appropriate to use it.

CONVERT performs character-by-character conversion.
EREPLACE replaces one substring with another.

You can use CONVERT to replace single characters with other single characters, including "".
However, if you want to replace one or more characters with more than one character, you need to use EREPLACE.
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