From: | Greg <grigorey(at)yahoo(dot)co(dot)uk> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Composite Types and Function Parameters |
Date: | 2010-10-25 22:38:23 |
Message-ID: | 802116.74667.qm@web29706.mail.ird.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Pavel, thanks! Yeah, thats what I though. I have to have a custom type or a
very ugly looking solution for passing the params then.
To Postgre dev. team: If anyone who involved in Postgre development reading
this, just a feature suggestion: allow array that can accept combination of any
data types to be passed to a function, for example:
// declare
create function TEST ( anytypearray[] ) ...
// calling
perform TEST (array[bool, int, etc.] ) ....
This would make such a nice adition to the development for postgre. Although
this may be complecated to achieve.
Thanks!
________________________________
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
Sent: Mon, 25 October, 2010 17:46:47
Subject: Re: [HACKERS] Composite Types and Function Parameters
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 | Tom Lane | 2010-10-25 22:51:40 | Re: Bug: citext not working in non-public schema |
Previous Message | Robert Haas | 2010-10-25 22:28:48 | Re: Range Types, discrete and/or continuous |