Re: Using rowtype parameter

Lists: pgsql-general
From: "Peter Zeltins" <peter(at)greatnowhere(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Using rowtype parameter
Date: 2006-01-19 12:04:52
Message-ID: 024201c61cf0$8e804ea0$0202fea9@komtek.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I'm trying to write a stored proc (in pl/Pgl) that can accept rowtypes as arguments:

CREATE or replace FUNCTION www_get_data(user_id "varchar", objectname "varchar", operation "varchar", primarykeyvalue anyelement, rowvalue anyelement)
RETURNS SETOF varchar[] AS
...

Whenever I try to typecast a rowtype in function call like this:

select www_get_data ('test','USERS','QUERY',CAST(('%','%','','','') as mytable),CAST(('%','%','','','') as mytable))

I get error message:

ERROR: could not determine actual argument type for polymorphic function "www_get_data"

What gives? I thought typecast should suffice? Are there any limitations on using composite data types for anyelement parms?

Peter


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Peter Zeltins" <peter(at)greatnowhere(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using rowtype parameter
Date: 2006-01-19 21:25:51
Message-ID: 9226.1137705951@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"Peter Zeltins" <peter(at)greatnowhere(dot)com> writes:
> I'm trying to write a stored proc (in pl/Pgl) that can accept rowtypes =
> as arguments:

> CREATE or replace FUNCTION www_get_data(user_id "varchar", objectname =
> "varchar", operation "varchar", primarykeyvalue anyelement, rowvalue =
> anyelement)
> RETURNS SETOF varchar[] AS

> select www_get_data ('test','USERS','QUERY',CAST(('%','%','','','') as =
> mytable),CAST(('%','%','','','') as mytable))

ANYELEMENT only matches scalar types. I don't think we have any support
for accepting an arbitrary row type as a function argument. There's
been some speculation about allowing RECORD to do that, but it's not
done.

regards, tom lane


From: "Peter Zeltins" <peter(at)greatnowhere(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using rowtype parameter
Date: 2006-01-20 09:28:28
Message-ID: 036f01c61da3$e0d2bd60$0202fea9@komtek.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> ANYELEMENT only matches scalar types. I don't think we have any support
> for accepting an arbitrary row type as a function argument. There's
> been some speculation about allowing RECORD to do that, but it's not
> done.

OK, that clears it up. RECORD would actually do nicely. Right now I'll be
forced to pass varchar/text arrays which can potentially lead to type
conversion issues.

Peter