teledb=# create or replace procedure p_goto(v_maxnum integer) as
$$
declare
maxnum integer;
begin
maxnum := v_maxnum;
for i in 1..maxnum loop
if i=3 then
goto label;
end if;
raise notice 'i=%',i;
end loop;
<<label>>
raise notice 'goto end';
end;
$$
language plpgsql;
CREATE PROCEDURE
teledb=# call p_goto(5);
NOTICE: i=1
NOTICE: i=2
NOTICE: goto end
CALL
teledb=#
go 用于跳转到某个标签下。