Carriage Return/Linefeed Character Removal

I'd like to remove CarriageReturn/Linefeed characters from varchar2 field data whenever I query that field. I was thinking of using the TRANSLATE function to do it, but I cannot figure out how to make SQL recognize that character. I've copied and pasted it from a SQL Plus query, but when I drop that character into my SQL code to TRANSLATE, SQL Plus jumps to the next line. I've tried enclosing that character in single quotes, but that did not work. Is there anyway to have the TRANSLATE function recognize this non-printing character, search for it, and replace it?

SQL> insert into ttest values ('a','Hi'||chr(10)||'World');
1 row created.
SQL> select * from ttest where col1='a';
COL COL2
a Hi
World
SQL> select * from ttest where translate(col2,chr(10),' ') like 'Hi Wo%';
COL COL2
a Hi
World

Similar Messages

  • Carriage Return/Linefeed Character Removal  for a CLOB variable

    Hi,
    Can anyone let me know how I can remove the carriage return from a CLOB variable.
    I tried the replace function
    REPLACE(D_MessageText, CHR(10)), it doesn't give any error,but the output still has the new line character.
    Any help would be really appreciated.
    Regards,
    Anil.

    chr(10) takes care of LINEFEED
    chr(13) takes care of CARRIAGE RETURN

  • How to handle carriage return/linefeed embedded in text field as first char

    Hi,
    I am trying to use sqlldr to import text that is comma-separated and double quote-enclosed, but contains embedded carriage return/linefeed pairs. I have a control file which works for most cases and looks like this:
    LOAD DATA
    INFILE './foo.new'
    APPEND
    CONTINUEIF LAST PRESERVE (<>'"')
    INTO TABLE <tablename>
    FIELDS TERMINATED BY "," ENCLOSED BY '"'
    TRAILING NULLCOLS
    Unfortunately, this fails when the very first character of the text field is a carriage return/linefeed pair, e.g.,:
    "11","22","33","\r\nThis is the fourth field","","","","",""
    In that case, what is actually the opening double-quote for the fourth field, is interpreted by the CONTINUEIF clause as the end of that line. Can anyone please point me to a solution?
    thanks.
    stan.

    Thanks for the suggestion. Unfortunately, I've already tried it, and it doesn't help. I believe the problem is that sqlldr tries to figure out where each record is delimited before it parses out the field. So, any field-level trimming depends on sqlldr first determining that the cr/lf is actually part of that record, and not an indication of the start of a new record (and it's doing the latter right now). Fwiw, Python's csv parser will handle this type of record just fine.
    regards.
    stan.

  • Carriage return symbol is removed from XML

    Hello,
    It looks like SQL Server removes \r characters when parsing XML. So when my stored procedure receives values in xml for saving, all line breaks are represented as \n instead of \r\n.
    Is there any way I can force SQL Server not to remove \r characters? In the sample below Node1 value doesn't contain \r symbols.
    DECLARE @hDoc int
    DECLARE @Xml nvarchar(MAX)
    SET @Xml = N'<Root><Node1><![CDATA[' + nchar(13) + nchar(10) + N'Some ' + nchar(13) + nchar(10) + N' Value]]></Node1></Root>'
    EXEC sp_xml_preparedocument @hDoc OUTPUT, @Xml
    SELECT
    Node1
    ,convert(varbinary(max),Node1) -- Contains 0A00 in the start instead of 0D0A,
    ,charindex(nchar(13),Node1)
    FROM
    OPENXML(@hDoc, N'/Root', 2) WITH (Node1 NVARCHAR(MAX))
    EXEC sp_xml_removedocument @hDoc
    Thank you

    Hi dalong,
    The scenario you pointed is the behavior of the XML processor by default. If any characters with CARRIAGE RETURN (#xD), whenever CARRIAGE RETURN (#xD) is followed by LINE FEED (#xA) or not, will be translate to a single #xA character, to normalize all line
    breaks in external parsed entities on input before parsing.
    In this case, you may have a try to make use of REPLACE function in the SELECT statement to replace “nchar(10)” to “nchar(13)+nchar(10)”.
    Best Regards,
    Stephanie Lv
    If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Carriage Return in External table column

    Im using Oracle 9.2.0.6 . On Aix.
    Ive created and external table pointing to a csv file.
    When I do a select on the last column of the external_table, it contains a carriage return / linefeed. If I try to make the colums specification smaller then it throws and error
    ORA-01401: inserted value too large for column
    How can I eliminate this unwanted character.
    line from csv file
    2,,,,,,,,,,,,,,BB
    table spec
    create table x_needsprop
    external_prop_ref varchar2(20),
    floor_level     varchar2(20),
    dcc     varchar2(4),
    lc     varchar2(4),
    ptd     varchar2(4),
    wc     varchar2(4),
    ec     varchar2(4),
    rspr     varchar2(4),
    err     varchar2(4),
    ctb     varchar2(4),
    bd     varchar2(4),
    nda     varchar2(4),
    ndd     varchar2(4),
    vsam     varchar2(4),
    res_type varchar2(5)
    ORGANIZATION EXTERNAL
    ( type oracle_loader
    default directory external_dir
    access parameters
    ( fields terminated by ',' )
    location ('needsprop.csv')
    /

    According to the documentation, adding the trim specifer 'RTRIM' directs that "spaces should be trimmed from the end of a text field. Spaces include blanks and other nonprinting characters such as tabs, line feeds, and carriage returns."
    create table x_needsprop
    external_prop_ref varchar2(20),
    floor_level varchar2(20),
    dcc varchar2(4),
    lc varchar2(4),
    ptd varchar2(4),
    wc varchar2(4),
    ec varchar2(4),
    rspr varchar2(4),
    err varchar2(4),
    ctb varchar2(4),
    bd varchar2(4),
    nda varchar2(4),
    ndd varchar2(4),
    vsam varchar2(4),
    res_type varchar2(5)
    ORGANIZATION EXTERNAL
    ( type oracle_loader
    default directory external_dir
    access parameters
    ( fields terminated by ',' RTRIM)
    location ('needsprop.csv')
    )

  • Address Book Adds Carriage Return to Street Field on Import

    I've been having some fun and games trying to import a large list of addresses in a tab delimited file into the Address Book. After finally managing to sort out all the issues with importing the file, I have now discovered that the value for the Street in all of the imported addresses has a carriage return (\r) character appended to them. There was not a carriage return present in the tab delimited file.
    I doublechecked the Address Book entries using Applescript to inspect the final character of the Street field and it was indeed a carriage return.
    I presume that this is due to the mapping of fields in the Address Book to the columns in my file. The Address Book allows you to enter 2 values for the Street, yet I am only using the first one with the second one being set to be ignored.
    However, the import still adds the carriage return character despite the second Street field not being required. It's not obvious that this is happening when viewing entries in the Address Book, yet when it comes to printing the imported addresses onto labels, a blank line is left due to the empty second Street field.
    If I edit the card and amend the Street field to, say, add a comma to the end of the Street or, take it away, the problem disappears. I don't want to manually edit all the imported address of which I have 275. Is there a workaround for this, or some Applescript that will automatically edit all the Street entries to remove the carriage return?
    Is anyone else experiencing this? Could this be classified as a bug?
    Before someone suggests I use the thirdparty Address Book Importer, I have tried that too and it also results in the same problem.
    Stuart
    Mac mini   Mac OS X (10.4.6)  

    The blank line appears when looking at the addresses through applications like SOHO Labels and Envelopes or Imprint. The problem is that the carriage return is added by the Address Book as it is being imported, rather than the carriage return being there already, so loading the tab delimited file into a spreadsheet will not show any carriage return characters.
    In the end I cooked up some Applescript to go through the Address Book and strip out any trailing carriage returns from the Street field for all addresses. I'm no Applescript guru, but the following seemed to do the trick:
    tell application "Address Book"
    set thePeople to every person
    repeat with thePerson in thePeople
    set theAddresses to every address of thePerson
    repeat with theAddress in theAddresses
    set streetinfo to street of theAddress
    if streetinfo ends with "\r" then
    set streetinfo2 to (text of characters 1 thru -2 of (streetinfo as string) as string)
    set street of theAddress to streetinfo2
    end if
    end repeat
    end repeat
    save addressbook
    end tell
    The other alternative was to write a script to parse my file in something like Ruby and then use Applescript to add the records rather than use the Address Book import feature. That would probably have given me some flexibility with being able to add multi-line notes, but the above was quicker to hack together.
    Stuart
    Mac mini (PPC)   Mac OS X (10.4.6)  

  • Default Carriage return in the last column when data is downloaded to Excel

    Problem:
    When you download data into Excel and if the last column of your excel is a numeric field, XMLP will add a carriage return (special character) to your numeric field. This feild will be considered as character field by excel.
    Work Around:
    When you build the template, create an empty column as your last column and leave E (or end-for-each) in that empty column.
    Note:
    If the last column is a character column then you do not have to do this.

    I originally had that END:VCARD without any carriage return.
    But I still get an extra carriage return at the end when the JSP renders to VCF
    I'm using Tomcat running on Linux.
    I found this, article which implies (but does not explicitly say) JSP in general adds a newline to the last line:
    http://www.caucho.com/resin-3.0/jsp/faq.xtp (But its not tomcat either, so maybe this info is irrelevant).
    Edited by: shogo2040 on Dec 22, 2008 3:31 PM - changed rendered to VCF from rendered to JSP

  • How do we remove Carriage Return (line feed) inserted in FCC files

    Hi Experts,
    The file that we generate has a carriage return at the end.
    Is there any way in which we can remove this carriage return (line feed) from the file?
    The FCC parameters used at our end are as below:
    structure.filedNames:
    structure.fieldFixedLengths:
    structure.fixedLengthTooShortHandling: Cut
    Kindly tell us a solution ASAP.
    Thanks & Regards
    Dhwani

    Dear All,
    Let me elaborate on my query
    Consider that the files output looks like below:
    12  34  45  545 5454 UL
    23  33  43  434 4545 FG
    45  44  44  586 6535 GM
    Now there is an extra line(Carriage Return) getting inserted after the last line 45  44  44  586 6535 GM  which is not required at our end.
    The cursor of the file instead of stopping on the last character M, points to the next line.
    Can you please suggest how to remove this extra line from the files.
    I dont understan how will remove context help in this case.
    Regards
    Dhwani

  • Carriage return in textarea - how do I check for and remove it???

    I have an html form that has a <textarea> element for user input. I work mainly with Java and some JavaScript. Since carriage returns are permitted in a <textarea> element, upon retrieving the value submitted, my Java and/or JavaScript variables contain carriage returns as well, making the values incomplete.
    For Example :
    String dataSubmitted = request.getParameter("formInput");
    <script language="JavaScript">
    var textValue = "<%=dataSubmitted%>";
    ....//do other stuff
    </script>When I view the source of my JSP page, the above statement of code looks like this:
    var textValue = "This is some text that
    I submitted with a carriage return";I'm putting the text submitted through this form into a mysql database, and when I pull up the values I find that it has recorded the carriage return as well. There is an actual symbol representing a carriage return in the db field.
    What I'd like to do is use some Java code to go through each character of the String and find and remove the carriage return, perhaps replacing it with an empty space instead. But how do I check for a carriage return in a String variable?
    Also, is there a way to use JavaScript to alert the user when the carriage return button is pressed when they're in the <textarea>?
    Any input is appreciated,
    Thank You,
    -Love2Java

    What I'd like to do is use some Java code to go through
    each character of the String and find and remove the
    carriage return, perhaps replacing it with an empty
    space instead. But how do I check for a carriage return
    in a String variable?The carriage return is represented by the \r. Generally there is also a newline, the \n. You can use String#replaceAll() to replace occurences of them by a space.
    string = string.replaceAll("\r\n", " ");
    Also, is there a way to use JavaScript to alert the user
    when the carriage return button is pressed when they're
    in the <textarea>?You can capture keys using the 'onkeypress' attribute. The keyCode of a the return key is 13. So simply catch that:<textarea onkeypress="if (event.keyCode == 13) alert('You pressed the return button.'); return false;"></textarea>The return false prohibits the linebreak being inserted. If you remove that, then it will be inserted anyway.

  • Handling Special character "Carriage Return" in PI

    Hi Experts,
    I have a scenario where JMs adapter is my source and is sending data which is of Fixed length.
    My problem is when JMS is sending the data in any of the incoming fields its passing a carriage return(0D- Hexadecimal character).
    When this character is coming the record is getting breaked into two or failing in my channel.
    Please guide me in handling this issue and to remove this character from the record.

    Hi,
    U can handle this issue by ant of these...
    1. U can ask the third party sending messages in JMS to replace the carriage return character by none or empty.. when they are sending it to the messaging system.
    But i dont think so they are ready to do it....
    2.No problem. U can handle this in the mapping itself.
    When the record is breaking because of carriage return, u will receive a new record.
    In UDF check the length of each record. If it is less than the Fixed Length we are expecting then combine these 2 records into one.
    Still less than the Fixed length append 3rd one also.. so on.
    U can go for one extra graphical mapping for this.
    And then other mapping which u will use noramally.
    in Operation Mapping specify them in sequence.
    Babu

  • Remove Carriage Return from a TextEdit field

    Hi All,
    I have a tableview, of which the last field Description, is of type TextEdit. Not only this, when the data was migrated from a legacy system to SAP, either the last field with the value (If Description has value, Description field, else the field before Description) has 2 '##' at the end of it.
    The 2nd # is EQ to
    cl_abap_char_utilities=>newline
    , which I can remove using
    REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN <fs> WITH ''.
    But the first # is having the Hex Value 0D00, which is EQ to Carriage Return. CR_LF is Carraige Return and Line Feed, but here, I need to remove only CR.
    Can anyone give me the right solution?
    I tried moving this data to a string field and then do a REPLACE All... IN BYTE MODE, but again, it didn't work.
    Thanks and Regards
    Gladson Jacob

    Hi Patrick,
    The program's ending with a Short Dump. The code snippet is as below.
    DATA: it_contract TYPE TABLE OF zbpa_bp_contract,
          xstring_val TYPE x VALUE '0D00',
          value2 TYPE x VALUE '2000',
          string_value TYPE string,
          xstring_value TYPE xstring,
          stringtable TYPE TABLE OF string,
          reply_value TYPE TABLE OF tline.
    FIELD-SYMBOLS <fs> TYPE zbpa_bp_contract.
    SELECT * FROM zbpa_bp_contract
      INTO TABLE it_contract.
    *  WHERE id BETWEEN 2316 AND 2328.
    LOOP AT it_contract ASSIGNING <fs>.
      string_value = <fs>.
      APPEND string_value TO stringtable.
      CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
        TABLES
          text_stream = stringtable
          itf_text    = reply_value.
    ENDLOOP.
    The dump description is as follows
    Error analysis
        At the statment "DESCRIBE" only character-type data objects are supported at the argument position "TEXT_STREAM", but no strings are supported (data types STRING and XSTRING).
        In this particular case, the operand "TEXT_STREAM" has the type "g".
    <b>Please help.</b>
    Thanks in advance.
    Gladson
    Message was edited by:
            Gladson Jacob
    Message was edited by:
            Gladson Jacob

  • Removing Carriage Returns

    I have a table with a field that contains data such as this,
    and I want to remove all of the carriage returns but I am having
    difficultiy. I have tried replacing the chr(13) and the chr(10) but
    no such luck. Can anyone help? Thanks!
    ==== start of code block ====
    Part Number: 1307 G9<BR>
    Finish Family:
    CHROMES<BR>
    Finish/Color:
    STERLING NICKEL<BR>
    Dimensions:
    1 1/4 INCH DIAMETER<BR>
    Collection:
    BRASS &amp; STERLING TRADITIONS<BR>
    ==== end of code block====

    Hi,
    For me both database as well as coldfusion worked fine. You
    may also please try with small example.
    Method 1:
    At database side
    select
    replace(columnname,chr(13)||chr(10),' ') as columnname
    from <tablename>
    Method 2: Coldfusion
    <cfset pageContent = reReplace(pageContent,
    chr(10)&chr(13),"", "all" )>
    I noticed that the regular expression functions in CF support
    the newline character \n Chr(10), carriage return \r Chr(13), and
    tab \t Chr(9).
    <cfsavecontent variable="data">
    here is my
    break
    </cfsavecontent>
    <cfoutput>#ReReplace(data, "\n", "<br />",
    "ALL")#</cfoutput>
    Method 3: Coldfusion.
    Please go through the below article. Example is mentioned
    http://livedocs.macromedia.com/coldfusion/6/CFML_Reference/functions-pt248.htm
    Hope this helps. Please try it out.
    Satheesh.

  • Removing the carriage return / Tab during data extraction

    Hi ,
      I have an issue with removing the carriage return / Tab from the extracted (Flat File) data from SAP EKPO table.
      1) While uploading(Long Back) the Legacy data to SAP tables the carriage returns and Tabs in Product description were uploaded to SAP tables.
      2) Now I am extracting data from bkpf,..EKPO.. tables  to a flat file . 
    3) When I extract the data i. PO number, Product description,......
    The Product description is going to 3 to 5 lines depending on the carriage returns and Tabs in the Product description.  Ekpo-txz01
    Ex : Mfg # DS104NA / NET######GEAR DS104 Hub######model
        I want  this product description in one continuous line. It is possible only  by removing the Carriage returns and tabs from product description before concatenating and TRANSFERING the file to Server.
    4) What is  getting:  The line is breaking @gear @ Hub due to Carriage return/Tab
    Mfg  D  NET
    GEAR DS104 Hub
    model   .
    5) What is required is: in one line
    Mfg  D  NETGEAR DS104 model
    In the process I am extracting product description from Ekpo-txz01 . So it is internal table. Now I want to remove the carriage return / Tab .
    How these can be removed.
    Thanks,
    Vasu

    Dear Vasu,
    Sometimes there is a problem that cannot be solved normally. This is one of them.
    The reason why the mentioned methods do not work is because you need to remove actually two characters CR and LF in one stroke. You can identify one but then not the other. So approach it from the other side.
    Simply define what your correct characters might be AND only use them to export.
    Below you will find a FORM routine that does just that (only passes defined valid characters and NOT others).
    FORM validate_field USING    VALUE(field_in)
                        CHANGING field_out.
    CONSTANTS:
    All low caps characters
      validlow(26)  TYPE c VALUE 'abcdefghijklmnopqrstuvwxyz',
    All upper caps characters and all figures
      validhigh(36) TYPE c VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    All other characters (starting with space)
      validrest(32) TYPE c VALUE ' <,>.?/:;"{[}]|\~`!@#$%^&*()_-+=',
    Single quote
      validquote           VALUE ''''.
      DATA:
        pos(1) TYPE c,         " Container to hold 1 character
        l      TYPE i,         " Length
        i      TYPE i.         " Indexer
    Determine length
      l = STRLEN( field_in ).
    Stripping loop
      WHILE i LT l.
      Get one character 
        pos = field_in+i(1).
      Check its validity
        IF pos CO validlow
        OR pos CO validhigh
        OR pos CO validrest
        OR pos EQ validquote.
        When valid, use it
          concatenate field_out
                      pos
                 into field_out.
        ENDIF.
      ENDWHILE.
    ENDFORM.
    Hopes this helps solving your problem.
    Regards,
    Rob.

  • What is escape character for for Carriage Return, Line Feed, Form Feed

    Hi
    I need to a text file which should have following characters
    Carriage Return, Line Feed, Form Feed
    How do i insert them in a string
    i know "\f" is carriage return,
    but what are characters for line feed and form feed
    Ashish

    uncle_alice wrote:
    jverd wrote:
    remus.dragos wrote:
    I forgot that it does not exist in Java. A good thing
    from my point of view.Running the following makes my computer beep.
    public class Bell {
    public static void main(String... args) {
    System.out.println("\u0007");
    Sure, sending a BEL character to the console rings the bell, but that has nothing to do with Java. Anyway, I think he meant Java doesn't support the \a escape sequence in string and char literals.
    >
    >
    >I forgot that it does not exist in Java. A good thing
    from my point of view.
    Running the following makes my computer beep.
    public class Bell {
    public static void main(String... args) {
    System.out.println("\u0007");
    } Sure, sending a BEL character to the console rings the bell, but that has nothing to do with Java. Anyway, I think he meant Java doesn't support the \a escape sequence in string and char literals.
    Ah, I thought he was saying Java doesn't support ringing the bell.

  • Remove carriage returns from a field in an oracle table

    I have a field that is defined as a LONG in my oracle table; the data contained in this field has carriage returns/line feeds (it's free form text); as i'm selecting data from this field, i need the carriage returns removed so that the data from this field all appears on one line.
    I tried using the TRANSLATE function to convert the carriage returns to something else, but that doesn't work.
    Example:
    Select comment from Notes:
    COMMENT
    the applicant called for an appointment;
    an exam was scheduled for 4/1/05 at 9am;
    called applicant to confirm app
    this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled for 4/1/05 at 9am; called applicant to confirm app"
    How can i do this? Can the decode function be used to remove the carriage returns in this field?

    when i used translate its giving correctly,
    SQL> ed
    Wrote file afiedt.buf
    1 select translate('the applicant called for an appointment;
    2 an exam was scheduled for 4/1/05 at 9am;
    3 called applicant to confirm app
    4 this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled
    5 How can i do this? Can the decode function be used to remove the carriage returns in this field
    6* ',' ') from dual
    SQL> /
    TRANSLATE('THEAPPLICANTCALLEDFORANAPPOINTMENT;ANEXAMWASSCHEDULEDFOR4/1/05AT9AM;CALLEDAPPLICANTTOCONF
    the applicant called for an appointment; an exam was scheduled for 4/1/05 at 9am; called applicant t
    SQL> ed
    Wrote file afiedt.buf
    1 select 'the applicant called for an appointment;
    2 an exam was scheduled for 4/1/05 at 9am;
    3 called applicant to confirm app
    4 this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled
    5* How can i do this? Can the decode function be used to remove the carriage returns in this field
    SQL> /
    'THEAPPLICANTCALLEDFORANAPPOINTMENT;ANEXAMWASSCHEDULEDFOR4/1/05AT9AM;CALLEDAPPLICANTTOCONFIRMAPPTHIS
    the applicant called for an appointment;
    an exam was scheduled for 4/1/05 at 9am;
    called applicant to confirm app
    this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled for 4
    How can i do this? Can the decode function be used to remove the carriage returns in this field?
    SQL>

Maybe you are looking for