I have a table who make a lot of time to delete some rows (32000 record by country). I create a function. I split the delete and use Loop instruction and commit but i have an error when i execute the function
My function DeleteMeasure :
CREATE OR REPLACE FUNCTION public.DeleteMeasure(
in_id_country integer)
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE AS $BODY$ DECLARE
err_pgsql_message TEXT;
_err_message TEXT;
nbdelete INTEGER=0;
BEGIN
LOOP
DELETE FROM public.measure WHERE id_measure IN (SELECT id_measure FROM public.measure WHERE id_country=in_id_country LIMIT 1000);
EXIT WHEN NOT FOUND;
COMMIT;
END LOOP;
RETURN nbdelete;
END
$BODY$;
Select * from DeleteMeasure();
Return an error on COMMIT line. Can i have some help?
callinstead ofselect. One of these things is wrong, you don't use a procedure or you don't use the proper syntax to invoke the procedure.limit=1000?