怎么循环输出一个表字段

如何循环输出一个表字段
看了书,不太明白.
下面是我的代码
--------------------

create   function   test()
define   v_product_id   decimal(20,0);
returning   decimal(20,0);
foreach  
select   first   100   product_id   into   v_product_id   from   product;
end   foreach;

execute   function   test();

----------------------------------------
我的目的是要输出product表中前一个product_id,如何写?


------解决方案--------------------
不太明白?
如果循环输出
可以使用游标来输出啊