CREATEOR REPLACEFUNCTION show_cities_multiple() RETURNSSETOFrefcursorAS $$ DECLARE ref1 refcursor; -- Declare cursor variables ref2 refcursor; BEGIN OPEN ref1 FORSELECT1; -- Open the first cursor RETURN NEXT ref1; -- Return the cursor to the caller
OPEN ref2 FORSELECT2; -- Open the second cursor RETURN NEXT ref2; -- Return the cursor to the caller END; $$LANGUAGE plpgsql;
procedure 返回多个游标
1 2 3 4 5 6 7 8 9
CREATE OR REPLACE PROCEDUREpublic.test_p1(INOUT ref refcursor[]) LANGUAGEplpgsql AS $procedure$ declareref0refcursor; ref1 refcursor; begin open ref0 for select 1; ref[0] = ref0; open ref1 for select 2; ref[1] = ref1; end; $procedure$