Re: Actualizar datos entre rango de fechas..

From: Giorgio PostgreSQL <giorgio(dot)pgsql(at)gmail(dot)com>
To: PostgreSQL <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Actualizar datos entre rango de fechas..
Date: 2009-07-10 20:25:08
Message-ID: c8a4ef220907101325j6ab796c1qbe7a12d16e646833@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hice la sgte funcion:

CREATE OR REPLACE FUNCTION "public"."f_dias_update" () RETURNS integer AS
$body$
DECLARE
vi_numerodia integer;
vdt_fechadesde timestamp;
vdt_fechahasta timestamp;
BEGIN

SELECT current_timestamp
INTO vdt_fechadesde;

SELECT current_timestamp + '10 DAYS'
INTO vdt_fechahasta;
SELECT MAX(numerodias) + 1
INTO vi_numerodia
FROM cobros
WHERE fecha_inicio = vdt_fechadesde
AND fecha_vencida = vdt_fechahasta;
UPDATE cobros
SET numerodias = vi_numerodia
WHERE fecha_inicio = vdt_fechadesde
AND fecha_vencida = vdt_fechahasta;

RETURN vi_numerodia;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;

//////////////////////////////////////////////////////////////////////////////

Lo que deseo es que me actualice (incrementando o contando los dias) entre 2
fechas (fecha_inicio y fecha_vencida) ejemplo si la fecha inicio es
01/07/2009 y la fecha vencida es 11/07/2009 en el campo numerodias vaya
sumando.

Quisiera q esta funcion se dispare una vez al dia desde la fecha de inicio
hasta la fecha vencida, si la coloco en al abrir mi aplicacion se va ir..
llenando o sumando (si se habre 20 veces por dar un ejemplo) solo quiero q
sume x dia, es por eso q quiero q se dispare una vez por dia

Que me recomiendan.

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Sandro Martin Napán Villarreal 2009-07-10 20:37:37 PARAMETROS
Previous Message Jaime Casanova 2009-07-10 19:43:34 Re: Actualizar datos entre rango de fechas..