Forum OpenACS Q&A: Response to Breakthrough on bookmarks module

Collapse
Posted by Bob Fuller on
<h2>Changes in delete-bookmark-2.tcl</h2>
<P>
The following changes were made to the <B>delete-bookmark-2.tcl</B> file:
<P>
<OL>
<LI>The following gets commented out:
<BLOCKQUOTE>
<PRE>
# set sql_child_delete "
#    delete from bm_list
#    where bookmark_id in (select      bookmark_id
#                          from        bm_list
#                      connect by  prior bookmark_id = parent_id
#                      start with  parent_id = $bookmark_id)
#    or bookmark_id = $bookmark_id"
</PRE>
</BLOCKQUOTE>
<LI>... and replaced by:
<BLOCKQUOTE>
<PRE>
set bookmark_sort_key [database_to_tcl_string $db "
  select case when parent_sort_key is null then local_sort_key
        else parent_sort_key || cast(local_sort_key as varchar(3)) end
  from bm_list where bookmark_id = $bookmark_id"]

set sql_child_delete "
  delete from bm_list
  where parent_sort_key like '$bookmark_sort_key%'
    or bookmark_id = $bookmark_id"`
</PRE>
</BLOCKQUOTE>
</OL>
<P>
(The theory here, in case anyone is interested, is that we avoid having
to use the Oracle proprietary CONNECT BY construct by very cleverly
leveraging the "sort keys" to produce the identical result!) I'd be happy
to explain this in more detail, if anyone wants to hear about it, since
my breakthrough in the bookmarks module hinges <I>precisely</I> on judicious
use of the sort keys, allowing us to avoid both the CONNECT BY construct
<B>and</B> the use of recursive function (or procedure) calls.
<P>
<HR>