Hola
ya lo resolvimos, les paso el script por si alguien lo necesita (tener en cuenta que no habia ningun alumno en el plan borrado):
SET SEARCH_PATH = ‘negocio’;
select * from sga_planes where propuesta=133
–plan 516
select * from sga_planes_versiones where plan =516
–plan_version 735
DELETE FROM sga_elementos_plan_aux WHERE plan_version = 735;
DELETE FROM sga_planes_certificados WHERE plan_version = 735;
DELETE FROM sga_requisitos_aplanado WHERE plan_version = 735;
DELETE FROM sga_elementos_plan_modalidad WHERE elemento_plan IN (SELECT elemento_plan FROM sga_elementos_plan WHERE plan_version = 735);
DELETE FROM sga_elementos_plan WHERE plan_version = 735;
–SELECT * FROM sga_condiciones_requisitos WHERE grupo_condicion IN (SELECT grupo_condicion FROM sga_condiciones_grupos WHERE condicion IN (select condicion FROM sga_condiciones WHERE plan_version = 735))
DELETE FROM sga_condiciones_requisitos WHERE grupo_condicion IN (SELECT grupo_condicion FROM sga_condiciones_grupos WHERE condicion IN (select condicion FROM sga_condiciones WHERE plan_version = 735))
DELETE FROM sga_condiciones_grupos WHERE condicion IN (select condicion FROM sga_condiciones WHERE plan_version = 735)
–SELECT * FROM sga_condiciones WHERE plan_version = 735;
DELETE FROM sga_condiciones WHERE plan_version = 735;
DELETE FROM sga_periodos_inscripcion_aplanado WHERE plan_version = 735;
DELETE FROM sga_planes_modalidad WHERE plan = 516;
UPDATE sga_planes SET version_actual=NULL WHERE version_actual = 735;
DELETE FROM sga_planes_versiones WHERE plan_version = 735;
DELETE FROM sga_planes where plan = 516;
saludos
Dalia