Re: [Pgsql-ayuda] Returns SETOF

From: Alvaro Herrera Munoz <alvherre(at)dcc(dot)uchile(dot)cl>
To: Carmen Gloria Sepulveda Dedes <csepulveda(at)atichile(dot)com>
Cc: pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx
Subject: Re: [Pgsql-ayuda] Returns SETOF
Date: 2003-11-20 21:19:41
Message-ID: 20031120211941.GE26865@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

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[(at)]dcc(dot)uchile(dot)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)

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Viaris hotmail 2003-11-20 21:53:52 Re: [Pgsql-ayuda] Ayuda para construir una consulta
Previous Message Alvaro Herrera Munoz 2003-11-20 21:08:09 Re: [Pgsql-ayuda] Super lento!!!Ayuda