return %ROWTYPE from function

From: Anton Prokofiev <a(dot)d(dot)prokofiev(at)googlemail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: return %ROWTYPE from function
Date: 2010-05-23 21:42:38
Message-ID: 0b4febda-32f3-4346-bb99-4d5197464f19@i31g2000vbt.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello, All!

I've tried to do following:

create table test ( id BIGSERIAL NOT NULL, constraint pk_test primary
key (id),
val BIGINT NOT NULL
);

create or replace function get_rec (in p_id test.id%TYPE) returns test
%ROWTYPE as $$
declare
retval test%ROWTYPE;
begin
select * from test into retval
where id = $1;
return retval;
end;
$$ language 'plpgsql';

I got an error message: "sysntax error at or near ROWTYPE"

Is it possible to return ONE record that has the same type as table?

I Oracle it is work fine....

Any Ideas or work around?

Thanks.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message jr 2010-05-24 01:15:25 Re: return %ROWTYPE from function
Previous Message Torsten Lange 2010-05-21 16:22:24 Re: Access Update error: solution.