PostgreSQL函数里调用函数(SETOF + RETURN QUERY)
PostgreSQL函数里调用函数(SETOF + RETURN QUERY)
1、函数如下:
CREATE OR REPLACE FUNCTION public.get_version()
RETURNS SETOF
text AS
$$
BEGIN
RETURN query
select version();
END
$$
language plpgsql;
2、实验记录:
postgres=# CREATE OR REPLACE FUNCTION public.get_version() RETURNS SETOF text AS
postgres-# $$
postgres$# BEGIN
postgres$# RETURN query
select * from version();
postgres$# END
postgres$# $$
postgres-# language plpgsql;
CREATE FUNCTION
postgres=#
postgres=#
postgres=# select get_version();
get_version
---------------------------------------------------------------------------------------------------------
PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit
(1 row)
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit
(1 row)
postgres=# select * from version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit
(1 row)
postgres=#
postgres=#
postgres=# CREATE OR REPLACE FUNCTION public.get_version1() RETURNS SETOF text AS
postgres-# $$
postgres$# BEGIN
postgres$# RETURN query
select version();
postgres$# END
postgres$# $$
postgres-# language plpgsql;
CREATE FUNCTION
postgres=# select get_version1();
get_version1
---------------------------------------------------------------------------------------------------------
PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit
(1 row)
postgres=# select * from get_version1();
get_version1
---------------------------------------------------------------------------------------------------------
PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit
(1 row)
postgres=#
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27126919/viewspace-2284475/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27126919/viewspace-2284475/
- return setof
- jdbc出现错误Before start of result set Query: select *
- About the return value of SetTimer function
- C语言之间函数(4)之Linux下设置时间的函数stime()和settimeofday()
- MySQL: Set user variable from result of query
- Linux系统调用--gettimeofday/settimeofday函数详解
- Django QuerySet的select_related()函数
- 【已解决】Object of type 'QuerySet' is not JSON serializable
- set command will return the value of the argument( variable, actually )
- C语言中settimeofday函数和gettimeofday函数的使用
- Windows文件处理函数 - SetEndOfFile
- python numpy.save 函数 SystemError: error return without exception set
- 《云计算》-shell高级编程-shell函数第二篇,return命令,函数中调用函数,递归函数调用,函数放在后台使用
- Django QuerySet的select_related()函数
- PostgreSQL: Query for location of global tablespace?
- LeetCode Online Judge:Given a set of distinct integers, S, return all possible subsets.
- python 内嵌函数中,return调用函数的区别
- The executeQuery method must return a result set
- return setof
- mysql_query(): Unable to save result set和Fatal error: Out of memory (allocated 2