How can I translate the FileNet ID ID in DB2/Oracle into friendly GUID?

て烟熏妆下的殇ゞ 提交于 2021-01-29 09:03:08

问题


The IBM Technote "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" outlines how DB2 & Oracle store guids in a byte reversed order. How can I convert them into a friendly guid?


回答1:


Presuming that object_id is char(16) for bit data, the following expression returns the same.

'{'||translate(
  'GHEFCDAB-KLIJ-OPMN-QRST-UVWXYZ012345'
, hex(F.object_id)
, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345')||'}' as object_id



回答2:


The following code does the trick in DB2, following the recipe from the IBM Technote:

‘{’ 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

The "cast as char(16)" is a gotcha - casting to varchar(16) does not work on DB2 at least.

Here's the before and after:



来源:https://stackoverflow.com/questions/53319982/how-can-i-translate-the-filenet-id-id-in-db2-oracle-into-friendly-guid

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