[GENERAL] Re: Use function to manipulate rows — how to get separate columns, rather than single row value
В списке pgsql-general по дате отправления:
| От | Guyren Howe |
|---|---|
| Тема | [GENERAL] Re: Use function to manipulate rows — how to get separate columns, rather than single row value |
| Дата | |
| Msg-id | 6857DDAA-9B83-4BF2-9E01-5CDADCC7624A@gmail.com обсуждение |
| Ответ на | [GENERAL] Use function to manipulate rows — how to get separate columns, rather than single row value (Guyren Howe <guyren@gmail.com>) |
| Список | pgsql-general |
On Apr 23, 2017, at 11:34 , Guyren Howe <guyren@gmail.com> wrote: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_rankedLANGUAGE plv8STABLE STRICT COST 1AS $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 cHow do I get the results as a full table?
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера