How to convert BLOB to varchar with SAP HANA database using SQL

旧巷老猫 提交于 2019-12-06 10:19:13

问题


how do I cast a blob to varchar with SAP HANA database using SQL.

(we need the column to be stored in blob - not TEXT - in else HANA automatically creates an index on this column. But we need an index with full-text-search and CORE_EXTRACTION)

The following code

select 
cast("DESCRIPTION" as varchar) "D"
from "DESC"

returns

Could not execute 'select cast("DESCRIPTION" as varchar) "D" from "DESC"' in 30 ms 168 µs . 
SAP DBTech JDBC: [266]: inconsistent datatype:  

回答1:


Solved the problem with this select statement

select cast(BINTOSTR(cast(description as binary)) as varchar) from xing_desc



回答2:


Casting to VARCHAR usually is done by

SELECT TO_ALPHANUM(col) FROM ...


来源:https://stackoverflow.com/questions/26633437/how-to-convert-blob-to-varchar-with-sap-hana-database-using-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!