问题
How can I substring a text of BLOB datatype in informix? If the operation is possible only on text of char datatype, is it possible to convert from BLOB to char (like to_char in oracle)?
Thanks in advance,
回答1:
You can use substring operator: http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.sqls.doc/sqls1069.htm
Code looks like:
select txt, txt[3,5] from _text_test
(txt is of BLOB type, but I also tested using TEXT type).
WARNING! In my tests such select gives different 2nd field values when executed by JDBC (correct values) and ODBC (seems incorrect). My ODBC Client is 3.70TC1, and JDBC.3.70.JC1DE. Please check if it works correctly in your environment. For txt value=1234567890 I got 123 using ODBC and 345 using JDBC. Seems like bug!
来源:https://stackoverflow.com/questions/4460623/substring-operation-on-blob-text-in-informix