例子一,不带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=# 

 

相关文章:

  • 2022-12-23
  • 2022-02-26
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2022-02-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
相关资源
相似解决方案