Jump to content

Ayuda con funcion de postgre


Recommended Posts

Tengo un problema con esto :@ ayuda!!!

en la siguiente consulta tengo un problema para cargar las consultas con rojo, al momento de entrar al while no hace ni una consulta.

 

CREATE OR REPLACE FUNCTION funciontotal()

RETURNS integer AS

$BODY$

DECLARE

Fechamin date;

Fechamax date;

contador INTEGER := 1;

cantidad INTEGER := 0;

lamoda character varying;

BEGIN

cantidad := count(distinct(auxiliar.partida)) from auxiliar;

 

while contador <= cantidad LOOP

lamoda := distinct(auxiliar.partida) from auxiliar limit 1 offset contador;

Fechamin := min(auxiliar.fecha) from auxiliar where auxiliar.partida = lamoda;

Fechamax := max(auxiliar.fecha) from auxiliar where auxiliar.partida = lamoda;

DELETE FROM la_tabla WHERE (la_tabla.fecha between Fechamin and Fechamax) AND (la_tabla.partida = lamoda);

contador:=contador+1;

END LOOP;

 

 

RETURN 1;

END;

$BODY$

LANGUAGE 'plpgsql' VOLATILE

COST 100;

ALTER FUNCTION funciontotal() OWNER TO postgres;

 

que esta malo?

 

gracias de antemano.

Edited by duff_jk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...