| From: | Richard Emberson <emberson(at)phc(dot)net> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: %ROWTYPE as PL/pgsql argument |
| Date: | 2002-04-02 03:02:55 |
| Message-ID: | 3CA91F5F.3231F6B9@phc.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Tom Lane wrote:
> Richard Emberson <emberson(at)phc(dot)net> writes:
> > CREATE OR REPLACE FUNCTION testFunc(mytable%ROWTYPE)
>
> There's no %ROWTYPE in Postgres SQL. There's no need for it, because
> the table name is also the name of the rowtype datatype --- so you
> should have written just
>
> CREATE OR REPLACE FUNCTION testFunc(mytable)
>
> regards, tom lane
The following does work ... (does the refcursor get closed automatically
in this example?)
CREATE OR REPLACE FUNCTION x(
BIGINT
)
RETURNS BIGINT AS '
DECLARE
type_id_p ALIAS FOR $1;
type_rc_v REFCURSOR;
BEGIN
OPEN type_rc_v FOR SELECT * FROM type
WHERE type_id = type_id_p;
RETURN xxx(type_rc_v);
END;
' LANGUAGE 'plpgsql' WITH (isstrict);
CREATE OR REPLACE FUNCTION xxx(
REFCURSOR
)
RETURNS BIGINT AS '
DECLARE
type_rc_p ALIAS FOR $1;
type_row_v type%ROWTYPE;
BEGIN
FETCH type_rc_p INTO type_row_v;
IF type_row_v.type_id IS NULL THEN
RETURN -2;
END IF;
RETURN type_row_v.type_kind;
END;
' LANGUAGE 'plpgsql' WITH (isstrict);
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dominic J. Eidson | 2002-04-02 03:41:48 | Errors when running vacuumdb... |
| Previous Message | Richard Emberson | 2002-04-02 03:00:05 | Re: %ROWTYPE as PL/pgsql argument |