Thread: Question about passing User defined types to functions
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.
> > 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
"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