Re: Question about passing User defined types to functions - Mailing list pgsql-sql

From Christoph Haller
Subject Re: Question about passing User defined types to functions
Date
Msg-id 3E3944C4.7D1226BE@rodos.fzk.de
Whole thread Raw
In response to Question about passing User defined types to functions  ("David Durst" <ddurst@larubber.com>)
List pgsql-sql
>
> CREATE TYPE dumby_type AS (dumby_id int4, dumby_name text);
>
> create function kick_dumby(dumby dumby_type) returns INTEGER AS '
> DECLARE
>   somenumber integer;
> BEGIN
>   return 1;
> END;
> ' language 'plpgsql';
>
>
> Is there some way of doing this, because the above doesn't work.
>
After having a look into the documentation on CREATE TYPE
I would say the statement looks very wrong. But I haven't done
any user defined type so far, so I can't be of any help in this case.
The CREATE FUNCTION statement is not considered to accept
parameter names within the parameter list.
So use
create function kick_dumby(dumby_type) returns INTEGER AS '
DECLAREdumby ALIAS FOR $1;
...

Regards, Christoph



pgsql-sql by date:

Previous
From: "Tambet Matiisen"
Date:
Subject: Re: Function executing twice
Next
From: Tom Lane
Date:
Subject: Re: Question about passing User defined types to functions