From: | "Jaime Casanova" <systemguards(at)gmail(dot)com> |
---|---|
To: | "Gabriel Hermes Colina Zambra" <hermeszambra(at)yahoo(dot)com> |
Cc: | gilberto(dot)castillo(at)etecsa(dot)cu, "pgsql-es-ayuda(at)postgresql(dot)org" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Funcion |
Date: | 2008-03-06 03:41:06 |
Message-ID: | c2d9e70e0803051941s20f08bb2vd535d189903c3daa@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
On Wed, Mar 5, 2008 at 8:09 PM, Gabriel Hermes Colina Zambra
<hermeszambra(at)yahoo(dot)com> wrote:
>
> --- Gilberto Castillo Martínez
> <gilberto(dot)castillo(at)etecsa(dot)cu> escribió:
>
> > Estoy utilizando esta función para que me devuelva
> > un select:
> >
> > CREATE OR REPLACE FUNCTION listarTipoDocumento(dato
> > "varchar")
> > RETURNS varchar AS
> > $BODY$
> > DECLARE
> >
> > lista_dato record;
> > BEGIN
> > IF dato isnull THEN
> > select * into lista_dato from
> > nom_tipo_documento;
> > END IF;
> > IF dato notnull THEN
> > select * into lista_dato from
> > nom_tipo_documento where
> > tipo_documento like '%dato%';
> > END IF;
> > RETURN lista_dato;
> > END;
> > $BODY$
> > LANGUAGE 'plpgsql' VOLATILE;
> >
>
> Te muestro un ejemplo muy adaptable al tuyo
>
mmm. creo que lo que lo que el busca es algo como esto:
CREATE OR REPLACE FUNCTION listarTipoDocumento(dato text)
RETURNS SETOF nom_tipo_documento AS
$$
select * from nom_tipo_documento
where case when $1 is not null then tipo_documento like '%' || $1 ||
'%' else true end;
$$
LANGUAGE 'sql';
--
Atentamente,
Jaime Casanova
From | Date | Subject | |
---|---|---|---|
Next Message | Silvio Quadri | 2008-03-06 11:20:34 | Re: Tablas Temporales |
Previous Message | Jaime Casanova | 2008-03-06 02:38:14 | Re: Tablas Temporales |