Re: How to assemble all fields of (any) view into a string?

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: How to assemble all fields of (any) view into a string?
Дата
Msg-id 90ae74a2-da89-a79c-325f-e9234ed5030c@BlueTreble.com
обсуждение исходный текст
Ответ на Re: How to assemble all fields of (any) view into a string?  (Ken Tanzer <ken.tanzer@gmail.com>)
Ответы Re: How to assemble all fields of (any) view into a string?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On 9/7/16 6:07 PM, Ken Tanzer wrote:
> ERROR:  PL/Python functions cannot accept type record

Ugh, yeah... that won't work. plperl might be able to do it, but I
suspect you're going to be stuck pulling the size info out of
info_schema or the catalog.

Actually, there is a way you could hack this via plpython; pass the row
in as text as well as the relation (regclass is good for that). You
could then do plpy.execute('SELECT (%::%).*'.format(row_text,
relation)); that should give you a dict just like Adrian's example did.

It would be nice if there was a function that accepted something with a
row descriptor and spit out the details of the descriptor.
http://pgxn.org/dist/colnames/doc/colnames.html comes close; if you know
much about C at all it shouldn't be hard to add a function to that
extension that returned the full details of the row. That and converting
the row to JSON would make it relatively easy to accomplish what you
want in a plpgsql (or maybe even plsql) function.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)   mobile: 512-569-9461


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

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: Clustered index to preserve data locality in a multitenant application?
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: IDE for function/stored proc development.