How to rewrite column raw(18) to informix

走远了吗. 提交于 2019-12-25 12:14:49

问题


in my application I have oracle column:

COLUMN_NAME RAW(18) not null

How should I rewrite it to informix ? I found that similar type is byte but I need also create index on this column which is not allowed on byte (in oracle on raw it is possible)


回答1:


I'm supposing are you working with version 12.10 of Informix.
This is little weird since at version 11.70 I'm able to use this same command without need to register the datablade.

Anyway, try this :

execute function SYSBldPrepare('binaryudt.*','create');

(expression)

           0

1 row(s) retrieved.


CREATE TABLE  bindata_test (int_col integer, bin_col binaryvar) ;
Table created.

At the onstat -m (or select * from sysmaster:sysonlinelog order by offset desc) you should see a message like this :

11:56:57  Unloading Module <$INFORMIXDIR/extend/ifxmngr/ifxmngr.bld>
11:56:57  The C Language Module <$INFORMIXDIR/extend/ifxmngr/ifxmngr.bld> unloaded



回答2:


From your comments it seems that you store bytes in this columns. Those bytes create UUID and in code you use bytes encoded in hexadecimal.

To store such data I would use VARCHAR(36). In hex encoding you need two chars for each byte so I used 36 as length (18 * 2).

In this solution your INSERT do not change. SELECT probably also do not change. Indexing is easy and works. For SELECT results you will have to decode hex string into bytes. You can do in in application code, or use stored function.

With other datatype like BYTE indexing may not work. I am also not sure if all drivers (JDBC, ODBC) can use text literal in SQL statements (INSERT/SELECT etc). Some drivers must use PreparedStatement with binary type.




回答3:


I found in new version of Informix data type: binaryvar and binary18: http://pic.dhe.ibm.com/infocenter/informix/v121/index.jsp?topic=%2Fcom.ibm.dbext.doc%2Fids_dbxt_386.htm I dont try it yet but I think raw(18) should be replace byt these data types

But I dont know how to create table with with column. When I try:

CREATE TABLE  bindata_test (int_col integer, bin_col binaryvar)

it return error:

Type (binaryvar) not found.

My database is logged and SELECT name,is_ansi FROM sysmaster:sysdatabases return 0 so it should work



来源:https://stackoverflow.com/questions/22476263/how-to-rewrite-column-raw18-to-informix

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