oracle8.1.6
select forums_forums_enabled.*,
(select count(*)
from forums_messages
where forums_messages.forum_id = forums_forums_enabled.forum_id
and parent_id is null) as n_threads,
to_char(last_post, 'YYYY-MM-DD HH24:MI:SS') as last_post_ansi,
case when last_post > (sysdate - 1) then 't' else 'f' end as new_p
from forums_forums_enabled
where forums_forums_enabled.package_id = :package_id
and (
forums_forums_enabled.posting_policy = 'open'
or forums_forums_enabled.posting_policy = 'moderated'
or 't' = acs_permission.permission_p(forums_forums_enabled.forum_id, :user_id, 'forum_read')
)
order by forums_forums_enabled.name