Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BLOB to String conversion - DB2

Tags:

blob

db2

sqoop

A table in DB2 contains BLOB data. I need to convert it into String so that it can be viewed in a readable format. I tried options like

  1. getting blob object and converting to byte array
  2. string buffer reader
  3. sqoop import using --map-column-java and --map-column-hive options.

After these conversions also i am not able to view the data in readable format. Its in an unreadable format like 1f8b0000..

Please suggest a solution on how to handle this scenario.

like image 499
Amrutha K Avatar asked Aug 11 '26 15:08

Amrutha K


1 Answers

I think you need to look at the CAST function.

SELECT CAST(BLOB_VAR as VARCHAR(SIZE) CCSID UNICODE) as CHAR_FLD

Also, be advised that max value of SIZE is 32K.

Let me know if you tried this.

like image 84
Vivek8086 Avatar answered Aug 13 '26 09:08

Vivek8086