Kotaa
Kotaa

Reputation: 201

A function returns data in a single column instead of 3 separate ones

I have a function as follows:

CREATE FUNCTION public.my_func(...)
  RETURNS TABLE(a integer, b timestamp without time zone, c timestamp without time zone) AS
$BODY$
BEGIN
    create temporary table t1 as
    select ....

RETURN QUERY
WITH RECURSIVE x AS ( working with t1 ..... ) SELECT x.a, x.b, x.c where ....;

When I call it as "select my_func(1, 2, 3)" it returns data in a single column:

result
-----------
(32, "7-dec-2016", "3-mar-2017")

I want it to return it in 3 separate columns. How?

Upvotes: 1

Views: 32

Answers (1)

Roman Tkachuk
Roman Tkachuk

Reputation: 3266

When you call function SELECT my_func(1, 2, 3) your result will be as record in one field. You need to run:

SELECT * FROM my_func(1, 2, 3);

Upvotes: 2

Related Questions