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.stehule@gmail.com> To: Greg <grigorey@yahoo.co.uk> Cc: pgsql-hackers@postgresql.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;
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 ....