postgresql7.1
select m.*,
tree_level(m.tree_sortkey) as tree_level,
forums_message__root_message_id(m.message_id) as root_message_id,
(select subject from forums_messages
where message_id = forums_message__root_message_id(m.message_id)) as root_subject,
to_char(m.posting_date, 'YYYY-MM-DD HH24:MI:SS') as posting_date_ansi
from forums_messages m
where m.message_id= :message_id
select m.*,
(select count(*) from attachments where object_id= message_id) as n_attachments,
forums_message__root_message_id(m.message_id) as root_message_id,
(select subject from forums_messages
where message_id = forums_message__root_message_id(m.message_id)) as root_subject,
to_char(m.posting_date, 'YYYY-MM-DD HH24:MI:SS') as posting_date_ansi
from forums_messages m
where m.message_id= :message_id
select forums_message__thread_close(:message_id);
select forums_message__thread_open(:message_id);