例子一,不带returns:
postgres=# CREATE FUNCTION sum_n_product(x int, y int, OUT sum int, OUT prod int) AS $$ postgres$# BEGIN postgres$# sum := x + y; postgres$# prod := x * y; postgres$# END; postgres$# $$ LANGUAGE plpgsql; CREATE FUNCTION postgres=# postgres=# select sum_n_product(3,4); sum_n_product --------------- (7,12) (1 row)
例子二,带returns:
postgres=# CREATE FUNCTION sum_n_product2(x int, y int, OUT sum int, OUT prod int) returns record AS $$ postgres$# BEGIN postgres$# sum := x + y; postgres$# prod := x * y; postgres$# END; postgres$# $$ LANGUAGE plpgsql; CREATE FUNCTION postgres=# postgres=# select sum_n_product2(3,4); sum_n_product2 ---------------- (7,12) (1 row) postgres=#