Re: funcion plpgsql

From: "Mario Soto" <msotocl(at)gmail(dot)com>
To: Javier Bermúdez Tito <javier_bt(at)hotmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: funcion plpgsql
Date: 2007-01-09 20:29:15
Message-ID: e9b17cde0701091229v502dc78bi1c2d9365b5ec1dd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

la he reescrito asi:

CREATE OR REPLACE FUNCTION "public"."get_rec" (varchar, integer,
varchar) RETURNS SETOF RECORD AS
'
DECLARE

tabla alias for $1;
codigo alias for $2;
tipo alias for $3;
qry RECORD;
query text;
BEGIN
query:= ''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'';
for qry in
execute query
loop
return next qry;
end loop;
return;
END;

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

y la ejecuto asi, pero aun nada.

select * from get_rec('public.analogico',158,'CATALOGOS')
AS foo(tipo varchar , seq integer );

No sera que la funcion no me esta tomando los parametros ?????

2007/1/9, Mario Soto <msotocl(at)gmail(dot)com>:
> aun asi no me funciona
>
> El 9/01/07, Javier Bermúdez Tito<javier_bt(at)hotmail(dot)com> escribió:
> > Me falto ponerle IN
> >
> > FOR rd_data IN SELECT s.idcsucur, s.saucnosu, s.saucdire FROM sucursales s
> > WHERE s.eliminar = 0 ORDER BY s.saucnosu ASC LOOP
> > ...
> >
> > pruebalo
> >
> > asi podras obtener todos los datos pruebalo y acondicionalo para tu consulta
> > segun tus criterios.
> >
> > CREATE OR REPLACE FUNCTION "public"."get_rec" (VARCHAR, INTEGER, VARCHAR)
> > RETURNS SETOF "public"."ty_rec" AS
> > $body$
> > DECLARE
> > rd_data ty_rec%ROWTYPE;
> > BEGIN
> > FOR rd_data SELECT s.idcsucur, s.saucnosu, s.saucdire FROM sucursales s
> > WHERE s.eliminar = 0 ORDER BY s.saucnosu ASC LOOP
> > RETURN NEXT rd_data;
> > END LOOP;
> > END;
> > $body$
> > LANGUAGE 'plpgsql';
> >
> > _________________________________________________________________
> > MSN Amor: busca tu ½ naranja http://latam.msn.com/amor/
> >
> >
>

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message GABRIEL COLINA 2007-01-09 20:37:48 Re: DBmanager Professional ¿alguien lo conoce?
Previous Message Agustin Casiva 2007-01-09 20:27:21 Re: Like iLike y Genexus