pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Question about passing User defined types to functions
3+ messages / 3 participants
[nested] [flat]

* Question about passing User defined types to functions
@ 2003-01-30 10:18  David Durst <ddurst@larubber.com>
  0 siblings, 1 reply; 3+ messages in thread

From: David Durst @ 2003-01-30 10:18 UTC (permalink / raw)
  To: pgsql-sql

is there a example on how to pass user defined types into
a function??

What I am looking for is something of this nature.

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.





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Question about passing User defined types to functions
@ 2003-01-30 15:29  Christoph Haller <ch@rodos.fzk.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Christoph Haller @ 2003-01-30 15:29 UTC (permalink / raw)
  To: pgsql-sql; +Cc: ddurst@larubber.com

>
> 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 '
DECLARE
 dumby ALIAS FOR $1;
...

Regards, Christoph




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Question about passing User defined types to functions
@ 2003-01-30 15:39  Tom Lane <tgl@sss.pgh.pa.us>
  parent: David Durst <ddurst@larubber.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2003-01-30 15:39 UTC (permalink / raw)
  To: ddurst@larubber.com; +Cc: pgsql-sql

"David Durst" <ddurst@larubber.com> writes:
> CREATE TYPE dumby_type AS (dumby_id int4, dumby_name text);

> create function kick_dumby(dumby dumby_type) returns INTEGER AS '

Should be

create function kick_dumby(dumby_type) returns INTEGER AS '...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-01-30 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-01-30 10:18 Question about passing User defined types to functions David Durst <ddurst@larubber.com>
2003-01-30 15:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-01-30 15:29 Re: Question about passing User defined types to functions Christoph Haller <ch@rodos.fzk.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox