Documentum DQL 通过重复属性连接
Documentum DQL join by repeating attribute
我尝试使用重复属性连接这些表:
表1:
r_object_id codes
... 1,2,3,4,5
... 7,6,3,4,5
... 1,5,4,2,3
其中 codes
属性是重复属性。
表2:
r_object_id name code
... hello 1
... aba 2
... father 3
... mother 4
... hello2 5
... hello3 6
... hello4 7
我想要这样的结果:
table1.r_object_id names
... hello,aba,father,mother,hello2
我能做什么?
这在一个 DQL 查询中是不可能的。但是你有一些解决方法。
1) 使用一个 DQL 但每行有一个重复值:
SELECT DISTINCT t1.r_object_id, t2.name FROM table1 t1, table2 t2 WHERE t1.codes = t2.code ENABLE(ROW_BASED)
结果会是这样的:
r_object_id name
0900ad1234567890 hello
0900ad1234567890 aba
0900ad1234567890 father
0900ad1234567890 mother
0900ad1234567890 hello2
0900ad1234567891 father
0900ad1234567891 mother
...
2) 在应用程序中配对值 - 例如使用 Java。您 select 通过一次查询 table2 中的所有记录并将它们存储到 Map<String, String> codeTable
,其中 code
属性作为键,name
属性作为一个值。然后 select 记录来自 table1 的另一个查询,并将来自重复属性 (codes) 的值与来自 [=15= 的值配对] 地图.
我尝试使用重复属性连接这些表:
表1:
r_object_id codes
... 1,2,3,4,5
... 7,6,3,4,5
... 1,5,4,2,3
其中 codes
属性是重复属性。
表2:
r_object_id name code
... hello 1
... aba 2
... father 3
... mother 4
... hello2 5
... hello3 6
... hello4 7
我想要这样的结果:
table1.r_object_id names
... hello,aba,father,mother,hello2
我能做什么?
这在一个 DQL 查询中是不可能的。但是你有一些解决方法。
1) 使用一个 DQL 但每行有一个重复值:
SELECT DISTINCT t1.r_object_id, t2.name FROM table1 t1, table2 t2 WHERE t1.codes = t2.code ENABLE(ROW_BASED)
结果会是这样的:
r_object_id name
0900ad1234567890 hello
0900ad1234567890 aba
0900ad1234567890 father
0900ad1234567890 mother
0900ad1234567890 hello2
0900ad1234567891 father
0900ad1234567891 mother
...
2) 在应用程序中配对值 - 例如使用 Java。您 select 通过一次查询 table2 中的所有记录并将它们存储到 Map<String, String> codeTable
,其中 code
属性作为键,name
属性作为一个值。然后 select 记录来自 table1 的另一个查询,并将来自重复属性 (codes) 的值与来自 [=15= 的值配对] 地图.