| From: | Johnny Moscoso Rossel <jomro(at)hotmail(dot)com> |
|---|---|
| To: | <pgsql-es-ayuda-owner(at)postgresql(dot)org>, <pgsql-es-ayuda(at)postgresql(dot)org> |
| Subject: | FW: Implementar Función |
| Date: | 2008-09-02 17:03:31 |
| Message-ID: | BAY112-W28AEF458CDAE8CFC8963E2BA5F0@phx.gbl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
From: jomro(at)hotmail(dot)com
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Implementar Función
Date: Tue, 2 Sep 2008 16:56:13 +0000
Hola soy neuvo en posgresql y necesito modificar esta función qeu realize con la idea de la tabala que em dio Alvaro; tengo esta función:
CREATE FUNCTION tramite.cant_dias_inhabiles (fecha_ini date, cant_dias integer) RETURNS int
AS '
declare
resultado int;
begin
SELECT count(dia_inh)
FROM tramite.dias_inhabiles // Tabla de valores de dias no habiles
WHERE fecha_ini <= dia_inh AND
dia_inh <= fecha_ini + cant_dias into resultado;
return resultado;
end
'
LANGUAGE plpgsql;
select tramite.cant_dias_inhabiles('2008-08-10', 20); // Que ejecutandola recibo el número de días inhabiles.
Pero quiero obtener la fecha mi idea es hacerla de la forma siguiente pero rpesenta error. :(
CREATE FUNCTION tramite.cant_dias_inhabiles (fecha_ini date, cant_dias integer) RETURNS date
AS '
declare
resultado int;
fecha date;
begin
SELECT count(dia_inh)
FROM tramite.dias_inhabiles
WHERE fecha_ini <= dia_inh AND
dia_inh <= fecha_ini + cant_dias into resultado;
fecha = fecha_ini + cant_dias + resultado; // Esta parte no se si se puede ejecutar ode que manera puede ejecutarse para que me devuelva por decir //2008-08-20
return fecha;
end
'
LANGUAGE plpgsql;
Gracias
Johnny Moscoso
Got Game? Win Prizes in the Windows Live Hotmail Mobile Summer Games Trivia Contest Find out how.
_________________________________________________________________
Get more from your digital life. Find out how.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home2_082008
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gilberto Castillo Martínez | 2008-09-02 17:16:18 | Re: PostgreSQL Spanish Documentation Project |
| Previous Message | Johnny Moscoso Rossel | 2008-09-02 16:56:13 | Implementar Función |