Rowtype or Record parameters to pl/pgsql functions

From: Diana Duncan <dianaduncan(at)nc(dot)rr(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Rowtype or Record parameters to pl/pgsql functions
Date: 2003-06-07 20:33:59
Message-ID: 5E55AE46-9927-11D7-9DBF-000A959D05EC@nc.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The documentation for section 19.3 Declarations for pl/pgsql states:
Parameters to a function can be composite types (complete table rows).
In that case, the corresponding identifier $n will be a row variable,
and fields can be selected from it, for example $1.user_id.

See
http://www.postgresql.org/docs/
view.php?version=7.3&idoc=1&file=plpgsql-declarations.html

But how is this declared in the function? When I attempt to declare a
function as follows:

CREATE FUNCTION "insert_history" (ip_resources_current%rowtype,
interval) RETURNS integer AS '
declare
v_currentRec alias for $1;
...

I get an error upon creation - ERROR: parser: parse error at or near
"%" at character 54

When I replace the %rowtype with the datatype record, the function is
created all right, but when it is called from another function with a
rowtype or a record variable named xrefrec, I get a runtime error -
ERROR: Attribute "xrefrec" not found

I can't seem to find any examples of this. I posted the observation in
the interactive docs, but figure I won't actually get an answer there.
So I'm hoping someone on the list will know? I tried searching the
archive, but I guess the database is down currently.

Thanks so much,

Diana Duncan
-- This message was written on a new Mac Powerbook G4 17". Yes, 17".
Cower, mortals!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Avi Schwartz 2003-06-07 23:50:36 Temporary tables inside functions problem
Previous Message Henrik Steffen 2003-06-07 20:13:16 Re: update phenomenom