Forum OpenACS Q&A: Re: Help needed porting a PG query to Oracle

Collapse
Posted by Dave Bauer on
What is this query trying to accomplish? I don't understand the tree sortkey part of this query if you already know which photo you want. I guess its trying to find the root folder that the photo is assoicated with?

Here is the similar query for the file storage package which uses a root folder concept as well.

select f.package_id as package_id
from fs_root_folders f,
(select i2.parent_id
from cr_items i1, cr_items i2, cr_revisions r
where i1.item_id = r.item_id
and r.revision_id = :revision_id
and i2.tree_sortkey <= i1.tree_sortkey
and i1.tree_sortkey i2.tree_sortkey and tree_right(i2.tree_sortkey)) as i
where f.folder_id = i.parent_id