stored procedure: RETURNS record

Поиск
Список
Период
Сортировка
От InterRob
Тема stored procedure: RETURNS record
Дата
Msg-id 671e36b0909250934u40e001cbge9ad1197a4a3de77@mail.gmail.com
обсуждение исходный текст
Ответы Re: stored procedure: RETURNS record  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Список pgsql-general
Dear list,

I am trying to find out whether I can use the "record" type as a polymorphic return type to return multiple columns, to be determined at runtime. In fact, I'm trying to write a function that provides a generic implementation of some deserialization of a certain field.

The prototype of the function I came up with, is as follows:
>> CREATE FUNCTION deserialize(the_table t1) RETURNS record << etc. etc. >> ;

It is intended to return multiple fields in an anonymous row: only at time of invocation it is known what fields will this row consist of...

The function is used in the following statement:

>> SELECT * FROM (SELECT deserialize( t1 ) FROM t1) ss;

Unfortunately, this results in ONE row, with ONE column. E.g.:

MYDB=# select * from (SELECT deserialize(kvp) FROM kvp) ss;
 deserialize
-----------
 (1,2)
(1 row)

I guess I am seeking to prototype the anonymous row layout in the above SQL statement?

Hope you have any idea,
regards,


Rob

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

Предыдущее
От: "Jerzy Bialas"
Дата:
Сообщение:
Следующее
От: John R Pierce
Дата:
Сообщение: Re: Delphi connection ?