Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2008
    Posts
    8

    carriage return in DB2

    Hi All,

    what is the carriage return character in DB2 (i.e enter key -new line)
    i was trying this char(13) but no luck...
    please help me out....

    SELECT 'first' || char(13) || 'second' FROM SYSIBM.SYSDUMMY1

    i want the result set to be
    first
    second

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    The answer is: it depends. It depends on the code page of the client whether you will get the output you have shown.

    However, you have 2 small issues:
    (1) CHAR(13) returns a string with the number 13 encoded in it. You probably want to use the CHR() function instead.
    (2) 13 is the ASCII character (so it only works if you have an ASCII client code page) for carriage return, i.e. the character that moves the cursor to the beginning of the line. If you want to move it to the beginning of the next line, you should use CHR(10).
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Jan 2008
    Posts
    8
    Hi,

    i tried this... but no luck
    SELECT 'FIRST' || CHR(10) || 'SECOND' FROM SYSIBM.SYSDUMMY1
    error: [SQL0204] CHR in *LIBL type *N not found

    i am using IBM i series operation navigator for sql queries...

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You neglected to mention the platfrom you are using. I tried the statement on DB2 LUW and it is working fine.

    Whether DB2 for iSeries supports something like CHR(), I do not know. Have you checked the manuals?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,734
    I believe that iSeries uses EBCDIC (like z/OS).
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •