stored procedure: RETURNS record - Mailing list pgsql-general

From InterRob
Subject stored procedure: RETURNS record
Date
Msg-id 671e36b0909250934u40e001cbge9ad1197a4a3de77@mail.gmail.com
Whole thread Raw
Responses Re: stored procedure: RETURNS record
List 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 by date:

Previous
From: "Jerzy Bialas"
Date:
Subject:
Next
From: John R Pierce
Date:
Subject: Re: Delphi connection ?