Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2015
    Posts
    24

    Unanswered: convert a column in DB2 table to HEX

    Hi all,

    I trying to convert a column in DB2 table to its HEX value by executing the following,

    select hex(column) from tablename;

    my column is of length 52 fields ( means it is varchar(52) ).

    the column value contains spaces and it is being converted to 4040404040..40
    which actually should convert to 202020202020....20

    why is this happening?


    Any reference on this would also be of great help.

  2. #2
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    40 hex is a space in EBCDIC.
    Is this db2 for z/os?
    Regards,
    Mark.

  3. #3
    Join Date
    Feb 2015
    Posts
    24
    @mark.b

    Thanks for the reply..

    yes db2 z/os.

    when i import this file to my PC and when i try to convert it to ascii i am getting wrong values.

    How can i convert it to ascii values in my local PC ?

    to convert this into ascii char i am using perl script...

  4. #4
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Use iconv utility instead.
    Regards,
    Mark.

  5. #5
    Join Date
    Feb 2015
    Posts
    24
    @mark.b

    thanks for the reply mark.

    I tried with iconv..

    iconv -f ISO8859-10 -t IBM-1046 <file>

    but it shows wrong conversion ..

  6. #6
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Try this to convert from EBCDIC to ASCII:

    iconv -f IBM-1047 -t ISO8859-1 file_ebcdic.txt > file_ascii.txt
    Regards,
    Mark.

Tags for this Thread

Posting Permissions

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