1 -- Create functions for monolith discussion widget.
2 -- Copyright (C) 2002 Richard W.M. Jones <rich@annexia.org>
3 -- This code is NOT REDISTRIBUTABLE. To use this widget you must purchase
4 -- a license at http://www.annexia.org/
6 -- $Id: ml_discussion_functions.sql,v 1.1 2003/02/22 12:49:21 rich Exp $
8 -- Function to count the number of unread articles in the given
11 create or replace function ml_discussion_unread (integer, integer)
15 my_userid alias for $1;
16 my_resid alias for $2;
22 stmt := ''select count (id) as result
23 from ml_discussion_article
24 where resid = '' || my_resid || ''
27 for rec in select low, high from ml_discussion_read
28 where resid = my_resid and userid = my_userid
30 stmt := stmt || '' or (id between '' || rec.low ||
31 '' and '' || (rec.high-1) || '')'';
34 stmt := stmt || '')'';
36 for rec in execute stmt