如何 SELECT 将函数中的多个值放入单独的列中?
How do I SELECT multiple values from a function into separate columns?
这是我的查询
SELECT
*
FROM (
SELECT
getlatlng("geom")
FROM
mytable
) AS subquery;
哪个return
(-121.9,36.4)
(-117.1,32.9)
(-121.9,36.5)
(-71.2,42.6)
我想写
SELECT
subquery.lat, subquery.lon
FROM (
SELECT
getlatlng("mygeom")
FROM
mytable
) AS subquery;
并拥有它 return
lat | lon
-------------
36.4 | -121.9
32.9 | -117.1
36.5 | -121.9
42.6 | -71.2
这是函数的相关位。
CREATE OR REPLACE FUNCTION getlatlng(geom geometry, OUT longitude text, OUT latitude text)
RETURNS record
LANGUAGE sql
IMMUTABLE
AS $function$
SELECT ...;
$function$
尝试:
SELECT (p).longitude, (p).latitude FROM (
SELECT getlatlng("mygeom") p
FROM mytable
) subquery
函数的 OUT
参数定义返回记录的列。
这是我的查询
SELECT
*
FROM (
SELECT
getlatlng("geom")
FROM
mytable
) AS subquery;
哪个return
(-121.9,36.4)
(-117.1,32.9)
(-121.9,36.5)
(-71.2,42.6)
我想写
SELECT
subquery.lat, subquery.lon
FROM (
SELECT
getlatlng("mygeom")
FROM
mytable
) AS subquery;
并拥有它 return
lat | lon
-------------
36.4 | -121.9
32.9 | -117.1
36.5 | -121.9
42.6 | -71.2
这是函数的相关位。
CREATE OR REPLACE FUNCTION getlatlng(geom geometry, OUT longitude text, OUT latitude text)
RETURNS record
LANGUAGE sql
IMMUTABLE
AS $function$
SELECT ...;
$function$
尝试:
SELECT (p).longitude, (p).latitude FROM (
SELECT getlatlng("mygeom") p
FROM mytable
) subquery
函数的 OUT
参数定义返回记录的列。