[Pgsql-ayuda] Returns SETOF

Alvaro Herrera Munoz alvherre@dcc.uchile.cl
Thu, 20 Nov 2003 18:19:41 -0300


On Thu, Nov 20, 2003 at 11:16:28AM -0300, Carmen Gloria Sepulveda Dedes wrote:

> CREATE TYPE X AS (
>       A    tipo_a,
>       B     tipo_b,
>       ...etc ...
> );
> 
> CREATE FUNCTION FX(INTEGER)
> RETURNS SETOF X AS
> '
>         SELECT T1.A as A,
>                           T2.B as B ....
>         FROM     T1, T2
>         WHERE  ...
> ' LANGUAGE 'sql';

No entendi tu ejemplo, y ademas pude hacer algo similar que si funciona.
Puedes mostrar un script que se pueda usar y que reproduzca tu problema?

create table a (uno int);
create table b (dos text);
insert into a values (1);
insert into a values (2);
insert into a values (3);
insert into b values ('uno');
insert into b values ('dos');
insert into b values ('tres');
create type tipo_a_b as (a integer, b text);
create function fx (int) returns setof tipo_a_b as 'select * from a, b' language sql;
select * from fx(1);

-- 
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
Thou shalt check the array bounds of all strings (indeed, all arrays), for
surely where thou typest "foo" someone someday shall type
"supercalifragilisticexpialidocious" (5th Commandment for C programmers)