From: | Gabriel Hermes Colina Zambra <hermeszambra(at)yahoo(dot)com> |
---|---|
To: | 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 01:09:43 |
Message-ID: | 368637.90140.qm@web63705.mail.re1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
--- 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;
>
> Pero me devuelve la cadena vacÃa ¿ que estoy
> haciendo mal? help.
>
> --
> TIP 6: ¿Has buscado en los archivos de nuestra lista
> de correo?
>
> http://archives.postgresql.org/pgsql-es-ayuda
>
Esto yo lo prefiero hacer en una funcion sql y no en
pl/pgsql
Te muestro un ejemplo muy adaptable al tuyo
-----"central"."carticulo_modelo" es un view, pero
podria ser una tabla.
CREATE OR REPLACE FUNCTION
"central"."fnc_articulo_modelo" (cid_articulo varchar)
RETURNS SETOF "central"."carticulo_modelo" AS
$body$
select * from central.carticulo_modelo where
id_articulo = $1 order by modelo,desde,hasta
$body$
LANGUAGE 'sql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
____________________________________________________________________________________
¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
http://correo.espanol.yahoo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Jenaro Centeno Gomez | 2008-03-06 01:42:25 | Tablas Temporales |
Previous Message | marcelo Cortez | 2008-03-06 00:06:49 | Re: Funcion |