Thread: return %ROWTYPE from function

return %ROWTYPE from function

From
Anton Prokofiev
Date:
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.


Re: return %ROWTYPE from function

From
jr
Date:
hi Anton,

works fine if you write:

create or replace function get_rec (in p_id test.id%TYPE) returns test as $$

-- 

regards, jr.  (jr@tailorware.org.uk)