Re: Help trying to write my first plpgsql function...
От | hubert depesz lubaczewski |
---|---|
Тема | Re: Help trying to write my first plpgsql function... |
Дата | |
Msg-id | 9e4684ce050916064752dd9928@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Help trying to write my first plpgsql function... (Bjørn T Johansen <btj@havleik.no>) |
Ответы |
Re: Help trying to write my first plpgsql function...
Re: Help trying to write my first plpgsql function... |
Список | pgsql-general |
On 9/15/05, Bjørn T Johansen <btj@havleik.no> wrote:
you did what? read the docs?
and?
as i said: define the function as setof something.
for example (i'm wrinting without testnig, so there might be small mistakes)
create type srf_type_1 ( field1 int4, field2 text);
create or replace function test () returns setof srf_type_1 as
$BODY$
declare
temprec srf_type_1%ROWTYPE;
begin
for temprec in select id as field1, username as field2 from users where is_active = true loop
return next temprec;
end loop;
return;
end;
$BODY$
language 'plpgsql';
should work as select * from test();
hubert
Yes, I did and I found an answer... :)
you did what? read the docs?
But I am trying to use this function in a report designer and the result from the
select is in the way of the real data from the fetch... Is there a way around this?
and?
as i said: define the function as setof something.
for example (i'm wrinting without testnig, so there might be small mistakes)
create type srf_type_1 ( field1 int4, field2 text);
create or replace function test () returns setof srf_type_1 as
$BODY$
declare
temprec srf_type_1%ROWTYPE;
begin
for temprec in select id as field1, username as field2 from users where is_active = true loop
return next temprec;
end loop;
return;
end;
$BODY$
language 'plpgsql';
should work as select * from test();
hubert
В списке pgsql-general по дате отправления: