Re: Function parameters of rowtype

From: Iker Arizmendi <iker(at)research(dot)att(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Function parameters of rowtype
Date: 2004-02-11 17:35:59
Message-ID: 402A67FF.3030502@research.att.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

But what if there is no table? Instead, is there
some way to specify the row tuple explicitly, similar
to what is done for arrays? I'd like to create a type
and define an instance of that type as part of the
SQL statement. For example,

CREATE TYPE user_t
{
id varchar,
pwd varchar
};

CREATE FUNCTION add_user(user_t)
RETURNS INT4 AS
DECLARE
p_user ALIAS FOR $1;
BEGIN
INSERT INTO user (id, pwd)
VALUES (p_user.id, p_user.pwd);
-- etc, etc, etc
END

then, from the client I might do something like:

SELECT add_user('{john, john123}');

with something like this I can get around Postgres'
limit of 32 parameters without having to compile a
custom version of the DB. One of the entities we're
working has many more than 32 parts which I'd rather
not have to split.

Regards,
Iker

Tom Lane wrote:
> Iker Arizmendi <iker(at)research(dot)att(dot)com> writes:
>
>>How are function parameters of rowtype specified when
>>calling them from a client such as libpq?
>
>
> Something like
> select myfunc(t.*) from tab t where ...
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Barbara Lindsey 2004-02-11 17:48:33 Re: pl/pythonu
Previous Message Josh Berkus 2004-02-11 17:29:07 Anyone used GForge?