【CQ】如何查询duplicate类型的上下游数据

来源:互联网 发布:爱宝价签软件 编辑:程序博客网 时间:2024/04/29 18:29

转载自IBM网站,有时候会用到
先是SQL查询的:
To create a query which returns Duplicate parent and child information in the result set:
  1. Create a new query.
  2. Select the ID field to display and select no filter fields. Run the query.
  3. Select the 'SQL editor' tab next to the 'Display editor' tab.
    Note: If you cannot see the 'SQL editor' tab, select View > View SQL pane from the menu. Then the SQL editor tab will become available.
  4. Make a change to the SQL command in the SQL editor tab. You will be prompted to confirm to continue.
  5. Select Yes and the SQL command will become editable.
  6. Replace the SQL command in the tab with the following SQL command using 'Ctrl + V' to paste it.
    1. To show all the records in duplicate state and include their parent IDs in the result set:

      select distinct T1.dbid, T1.id, T2.id as "Duplicate Of" 
      from Defect T1, Defect T2, parent_child_links l 
      where T1.dbid <> 0 and (T1.dbid = l.child_dbid 
      and l.parent_dbid = T2.dbid and l.link_type_enum=2)
    2. To show all the records which have duplicate records and include their duplicate IDs in the result set :

      select distinct T1.dbid, T1.id, T2.id as "Duplicates" 
      from Defect T1, Defect T2, parent_child_links l 
      where T1.dbid <> 0 and (l.parent_dbid = T1.dbid 
      and l.child_dbid = T2.dbid and l.link_type_enum=2)
  7. Run the Query
程序方法获取,提供方法,可自己查看api说明
GetOriginal  获取父记录对象
GetOriginalID 获取父记录ID
GetDuplicates 获取子记录集合
IsOriginal 是否父记录类型
IsDuplicate 是否子记录类型