devdoc

Tuesday, May 10, 2005

DQL: Retrive the child components in virtual document

If you have the r_object_id of a Virtual Document you always can launch the following DQL:



SELECT r_object_id FROM dm_sysobject
IN DOCUMENT ID('virtual_doc_id') DESCEND


But if you don't have the r_object_id and you want to extract the child components with a sigle query you must execute:


SELECT r_object_id,object_name,r_object_type,r_content_size,
a_content_type,r_is_virtual_doc,r_link_cnt,r_lock_owner,
a_content_type,owner_name,i_is_reference
FROM dm_document
WHERE r_is_virtual_doc <> 1 AND
i_chronicle_id IN (
SELECT component_id
FROM dmr_containment
WHERE parent_id = 'Virtual_Doc_ID'
)

If you want, for example, to retrieve all the child components from a virtual doc associated to a task you could launch the following query:


SELECT r_object_id,object_name,r_object_type,r_content_size,
a_content_type,r_is_virtual_doc,r_link_cnt,
r_lock_owner,a_content_type,owner_name,i_is_reference
FROM dm_document
WHERE r_is_virtual_doc <> 1 AND
i_chronicle_id IN (
SELECT component_id
FROM dmr_containment
WHERE parent_id IN (
SELECT distinct r_component_id
FROM dmi_package
WHERE r_workflow_id IN (
SELECT router_id
FROM dmi_queue_item
WHERE r_object_id='TASK_ID'
)
)
)

2 Comments:

  • Hi,

    does "virtual_doc_id" from the first example differs from "Virtual_Doc_ID" in the second example? I thought that virtual documents has always the id of existing dm_document that acts as container.

    Cheers!

    Jakub

    By Blogger Jakub Gemrot, at 3:27 AM  

  • Oh I see,

    you've meant the second example as a template ... that you can substitute the 'Virtual_Doc_ID' with something else.

    Cheers!

    Jakub

    By Blogger Jakub Gemrot, at 3:47 AM  

Post a Comment

<< Home