[GENERAL] Use function to manipulate rows — how to get separate columns, rather than single row value

Поиск
Список
Период
Сортировка
От Guyren Howe
Тема [GENERAL] Use function to manipulate rows — how to get separate columns, rather than single row value
Дата
Msg-id ABBF737B-A71F-48B9-81A9-2A0F8546D45A@gmail.com
обсуждение исходный текст
Ответы [GENERAL] Re: Use function to manipulate rows — how to get separate columns, rather than single row value
Список pgsql-general
I’m trying to write a function that manipulates whole rows. It returns the same type as the table it is being applied to, but when I select the function on the rows, I get a single column of row type, rather than separate columns.

My function looks like:

CREATE OR REPLACE FUNCTION reporting.formatted_cust_by_state_bold(c reporting_helpers.customers_by_state_ranked)
 RETURNS reporting_helpers.customers_by_state_ranked
 LANGUAGE plv8
 STABLE STRICT COST 1
AS $function$
if (c.rank == 1) {
c['_meta'] = c['meta'] || {}
c['_meta']['raw'] = c['_meta']['raw'] || {}
c['_meta']['raw']['spent'] = c['_meta']['raw']['spent'] || {}
c['_meta']['raw']['spent'] = "<b>" + c.spent + "</b>"
}
return c
$function$

I do this:

SELECT formatted_cust_by_state_bold(c) FROM customers_by_state_ranked c

How do I get the results as a full table?

В списке pgsql-general по дате отправления:

Предыдущее
От: Guyren Howe
Дата:
Сообщение: Re: [GENERAL] Does a view not define a composite type?
Следующее
От: Guyren Howe
Дата:
Сообщение: [GENERAL] Re: Use function to manipulate rows — how to get separate columns, rather than single row value