如何将 DB2/Oracle 中的 FileNet ID ID 转换为友好的 GUID?
How can I translate the FileNet ID ID in DB2/Oracle into friendly GUID?
IBM 技术说明“How to translate the unique identifier as displayed within FileNet Enterprise Manager so that it matches what is stored in the Oracle and DB2 databases”概述了 DB2 和 Oracle 如何以字节反转顺序存储 uuid。如何将它们转换成友好的 GUID?
按照 IBM Technote 中的配方,以下代码在 DB2 中发挥作用:
‘{’ concat upper(VARCHAR_FORMAT_BIT(
cast(substring(F.Object_id, 4, 1) concat
substring(F.Object_id, 3, 1) concat
substring(F.Object_id, 2, 1) concat
substring(F.Object_id, 1, 1) concat
substring(F.Object_id, 6, 1) concat
substring(F.Object_id, 5, 1) concat
substring(F.Object_id, 8, 1) concat
substring(F.Object_id, 7, 1) concat
substring(F.Object_id, 9) as char(16)), ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’)) concat ‘}’ as object_id
"cast as char(16)" 是一个陷阱 - 转换为 varchar(16) 至少在 DB2 上不起作用。
前后对比如下:
假设object_id是char(16) for bit data
,下面的表达式returns一样。
'{'||translate(
'GHEFCDAB-KLIJ-OPMN-QRST-UVWXYZ012345'
, hex(F.object_id)
, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345')||'}' as object_id
IBM 技术说明“How to translate the unique identifier as displayed within FileNet Enterprise Manager so that it matches what is stored in the Oracle and DB2 databases”概述了 DB2 和 Oracle 如何以字节反转顺序存储 uuid。如何将它们转换成友好的 GUID?
按照 IBM Technote 中的配方,以下代码在 DB2 中发挥作用:
‘{’ concat upper(VARCHAR_FORMAT_BIT(
cast(substring(F.Object_id, 4, 1) concat
substring(F.Object_id, 3, 1) concat
substring(F.Object_id, 2, 1) concat
substring(F.Object_id, 1, 1) concat
substring(F.Object_id, 6, 1) concat
substring(F.Object_id, 5, 1) concat
substring(F.Object_id, 8, 1) concat
substring(F.Object_id, 7, 1) concat
substring(F.Object_id, 9) as char(16)), ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’)) concat ‘}’ as object_id
"cast as char(16)" 是一个陷阱 - 转换为 varchar(16) 至少在 DB2 上不起作用。
前后对比如下:
假设object_id是char(16) for bit data
,下面的表达式returns一样。
'{'||translate(
'GHEFCDAB-KLIJ-OPMN-QRST-UVWXYZ012345'
, hex(F.object_id)
, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345')||'}' as object_id