postgresql7.2
select content_keyword__new (:heading,
:description,
:parent_id,
null,
now(),
:creation_user_id,
:creation_ip,
'content_keyword')
select content_keyword__delete (:category_id)
select c.keyword_id as category_id, c.parent_id, c.heading,
c.description, content_keyword__get_path(c.keyword_id) as path
from cr_keywords c,
(select keyword_id, tree_sortkey from cr_keywords where keyword_id = :parent_id) p
where
c.tree_sortkey between p.tree_sortkey and tree_right(p.tree_sortkey)
order by c.tree_sortkey;
select keyword_id as category_id, parent_id, heading, description, has_children
from cr_keywords k,
(select tree_sortkey from cr_keywords where keyword_id = :category_id) c
where k.tree_sortkey = tree_root_key(c.tree_sortkey);
(select keyword_id as category_id, heading, :prepend_path || content_keyword__get_path_id(keyword_id) as path
from cr_keywords
where keyword_id = :root_id)
union
(select keyword_id as category_id, heading, :prepend_path || content_keyword__get_path_id(keyword_id) as path
from cr_keywords c,
(select tree_sortkey from cr_keywords where keyword_id = :root_id) r,
(select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_keywords where keyword_id = :category_id) p
where
c.tree_sortkey = p.tree_sortkey
and c.tree_sortkey > r.tree_sortkey
order by c.tree_sortkey)