return %ROWTYPE from function - Mailing list pgsql-sql

From Anton Prokofiev
Subject return %ROWTYPE from function
Date
Msg-id 0b4febda-32f3-4346-bb99-4d5197464f19@i31g2000vbt.googlegroups.com
Whole thread Raw
Responses Re: return %ROWTYPE from function  (jr <jorg.raskowski@tailorware.org.uk>)
List 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.


pgsql-sql by date:

Previous
From: Harrie Rodenbach
Date:
Subject: Re: Do not understand "SETOF RECORD" - therefore can not use ODBC-link
Next
From: jr
Date:
Subject: Re: return %ROWTYPE from function