Re: funcion plpgsql

From: "Mario Soto" <msotocl(at)gmail(dot)com>
To: "Mario Soto" <msotocl(at)gmail(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: funcion plpgsql
Date: 2007-01-09 19:44:01
Message-ID: e9b17cde0701091144n7d7ba6c1qd410e6be1e8658b3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

OK, la cambie:

CREATE OR REPLACE FUNCTION "public"."get_rec" (varchar, integer,
varchar) RETURNS SETOF "public"."ty_rec" AS
'
DECLARE
tabla alias for $1;
codigo alias for $2;
tipo alias for $3;
recordSalida record;
qry text;
BEGIN
for recordSalida in
execute ''select b.nb_tipo as tipo, a.co_codigo as codigo,
a.nb_tipo as tp1,
a.nb_nombre as nombre, a.sq_serialcolumn as seq, a.userid
from '' || tabla || '' a, systab01 b
where
a.co_codigo = '' || codigo || '' and
a.co_codigo = b.sq_serialcolumn and
b.nb_tipo = '''' || tipo || ''''
order by a.nb_tipo asc''
loop
return next recordSalida;
end loop;
return;
END;

' LANGUAGE 'plpgsql' volatile called on null input security invoker;

pero aùn asi no me retorna nada

El 9/01/07, Alvaro Herrera<alvherre(at)commandprompt(dot)com> escribió:
> Mario Soto escribió:
>
> > BEGIN
> > qry := ''select [...]
> > order by a.nb_tipo asc'';
> > EXECUTE qry;
> > return;
> > END;
> >
> > ' LANGUAGE 'plpgsql';
> >
> > cuando la ejecuto de esta forma, no me da ningun resultado.
> > select * from get_rec('public.analogico',158,'CATALOGOS')
>
> Claro que no, porque el RETURN esta vacio. Debes usar un loop FOR y
> usar RETURN NEXT para cada registro.
>
> --
> Alvaro Herrera http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Javier Bermúdez Tito 2007-01-09 19:45:22 RE: funcion plpgsql
Previous Message Javier Bermúdez Tito 2007-01-09 19:34:44 RE: funcion plpgsql