Re: anonymous record as an in parameter

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Maximilian Tyrtania <lists(at)contactking(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: anonymous record as an in parameter
Date: 2011-03-29 14:06:32
Message-ID: AANLkTikV92SHsds7uBSr4nb75UEFcDuhKSeGRaA6=RzM@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Mar 29, 2011 at 8:07 AM, Maximilian Tyrtania
<lists(at)contactking(dot)de> wrote:
> Hi there,
>
> i'd like to write a function (sql or plpgsql) that takes an anonymous record as an in parameter. You know, kind of like (simplified):
>
> create function f_tablename (p_anyrecord record) returns text as
> $body$
> select $1.tableoid::regclass::text
> $body$
> language sql;
>
> ...but PG 9.0.3 doesn't like that:
> ERROR:  SQL functions cannot have arguments of type record. It also doesn't work with plpgsql.
> Is there a way?

yes, in C, which is maybe 10 notches up in the difficulty level. my
advice is to cast the record to text, or use an hstore.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ogden 2011-03-29 14:11:53 Load Increase
Previous Message Adrian Klaver 2011-03-29 14:03:48 Re: Autocommit off - commits/rollbacks