FOR循环查询结果

最近更新时间: 2024-06-12 15:06:00

postgres=# CREATE OR REPLACE FUNCTION f27() RETURNS VOID AS
postgres-# $$    
postgres$# DECLARE
postgres$#     v_rec RECORD;
postgres$# BEGIN           
postgres$#     FOR v_rec IN SELECT * FROM public.t LOOP
postgres$#         RAISE NOTICE '%',v_rec;
postgres$#     END LOOP;
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# SELECT f27();
NOTICE:  (1,TBase)
NOTICE:  (2,pgxz)
 f27 
-----
(1 row)