FUNCTION my_func;
DECLARE CURSOR c IS SELECT word, doc_count, first_doc_id, last_doc_id, ilist
 FROM $table_name WHERE word >= :word;
BEGIN

OPEN c;
WHILE 1 = 1 LOOP
  FETCH c INTO my_func();
  IF c % NOTFOUND THEN
    EXIT;
  END IF;
END LOOP;
CLOSE c;