Re: Couldn't cast to record[]

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Couldn't cast to record[]
Дата
Msg-id CAFj8pRDcHJmpKPJ-QYiL8H1k1tj_dPA0AXuc7Vm1CPnGLKvCGg@mail.gmail.com
обсуждение исходный текст
Ответ на Couldn't cast to record[]  (Suresh Kumar R <suresh.arsenal29@gmail.com>)
Список pgsql-general
Hi

čt 3. 3. 2022 v 11:01 odesílatel Suresh Kumar R <suresh.arsenal29@gmail.com> napsal:
Hi, I created an table with composite type array as datatype for one column.
When I query that table I need the pg_typeof(column) as record[] instead of
composite_type[].
I tried creating a separate function and returning record[], but below error
is thrown,

ERROR:  PL/pgSQL functions cannot return type record[]

Below is sample for my requirement.

pali=# create type address as (number bigint, city varchar);
CREATE TYPE
pali=# create table person(name varchar, addresses address[]);
CREATE TABLE
pali=# insert into person values ('Michael', array[(82, 'NYC'),(24,
'Dunkirk')]::address[]);
INSERT 0 1
pali=# select pg_typeof(addresses::record[]) from person ;
 pg_typeof
-----------
 address[]

Here I expect record[] instead of address[].

Thanks in advance.

record type is not real PostgreSQL's type. It is just PLpgSQL only type. You cannot use it outside PLpgSQL.

Regards

Pavel
 

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

Предыдущее
От: Suresh Kumar R
Дата:
Сообщение: Couldn't cast to record[]
Следующее
От: "Daniel Westermann (DWE)"
Дата:
Сообщение: oid2name: Why table and not relation?