From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Greg <grigorey(at)yahoo(dot)co(dot)uk> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Composite Types and Function Parameters |
Date: | 2010-10-25 16:46:47 |
Message-ID: | AANLkTi=NOJzWxMMiFA+tBLLZa44Q1Do1Qy5Cx=g1E_ra@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
I am thinking, so it isn't possible. There are a general datatype
anyelement, but it cannot accept a second general type record.
CREATE TYPE p AS (a text, b int, c bool);
CREATE OR REPLACE FUNCTION fp(p)
RETURNS int AS $$
BEGIN RAISE NOTICE 'a = %', $1.a; RETURN $1.b;
END;
$$ LANGUAGE plpgsql;
postgres=# select fp(row('hello',10, false));
NOTICE: a = hello
fp
────
10
(1 row)
Regards
Pavel Stehule
Time: 0.814 ms
postgres=# select fp(row('hello',10, false));
2010/10/25 Greg <grigorey(at)yahoo(dot)co(dot)uk>
> Hi guys, got across an interesting problem of passing params to a function
> in postgre: is it possible to pass a composite parameter to a function
> without declaring a type first?
>
> For example:
>
> // declare a function
> create function TEST ( object??? )
> ....
> object???.paramName // using parameter
> ....
>
> // calling
> perform TEST( ROW(string, int, bool, etc...) )
>
> Or do I have to do the type declaration for that parameter?
>
> Thanks!
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2010-10-25 16:51:05 | Re: Range Types, discrete and/or continuous |
Previous Message | Peter Eisentraut | 2010-10-25 16:45:44 | Re: add label to enum syntax |