On Fri, 19 Apr 2002, Tom Lane wrote:
> "Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:
> > Obviously I can't use the RECORD type but when I create the function with:
> > CREATE FUNCTION myfunction (myview%ROWTYPE) RETURNS ... ;
> > the '%' gets reported in an error message.
>
> Leave off the %ROWTYPE. Also read the info about composite-type
> arguments at
> http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/xfunc-sql.html
Thanks Tom. I didn't read that particular page before, I had been concentrating
on the PL/pgSQL pages.
As soon as I'd read that page I had the function being created. Unfortunately,
I can't now get the rule to be created. Again, I can't find the relevent
information in the docs, even though it's probably obvious again, so any help
on why this:
CREATE RULE insert_listing AS ON insert TO listing_view
DO INSTEAD SELECT insert_listing_fn(NEW);
gives the error: 'parser: parse error at or near ")"' would be appreciated.
Using:
1) SELECT 1,2,3
2) SELECT NEW.title
3) SELECT insert_listing_fn()
4) SELECT insert_listing_fn(NEW.title)
as the rule's action do not give this error, although 3 and 4 do of course give
a different error since there aren't version of the function defined with those
parameters.
I know I could just expand the NEW record in the call to the function, giving
each attribute as a parameter. However, I'd be more interested in knowing how
to do this properly.
--
Nigel J. Andrews
Director
---
Logictree Systems Limited
Computer Consultants