DO --关键字
$serch$ --$中间随便写, 不能用特殊符号和数字好像$
DECLARE times integer; --定义变量
rec history_depart%ROWTYPE; -- 定义行变量
BEGIN
times := 0;
FOR rec in SELECT * FROM history_depart WHERE person_id = 5655 LOOP --几种循环的一种 循环查到的结果 另几种查看 https://www.cnblogs.com/stephen-liu74/archive/2012/06/06/2312759.html
times:=times+1;
RAISE NOTICE 'LOOP % %',times,rec.history_depart_id;
END LOOP;
END
$serch$ LANGUAGE PLPGSQL
DO --关键字
$serch$ --$中间