-- GENERACION DE INSCRIPCIONES A CURSADAS -- PRE-REQUISITOS. -- TENER INSCRIPCIONES A PROPUESAS Y ALUMNOS EN LA BASE -- TENER COMISIONES CREADAS BEGIN WORK; -- INSCRIPCIONES INSERT INTO sga_insc_cursada (comision, alumno, prioridad, plan_version, fuera_de_termino, estado) SELECT c.comision,a.alumno, 1, a.plan_version, 'N','A' FROM sga_comisiones as c, sga_periodos_lectivos as pl, sga_periodos as p,sga_alumnos as a WHERE c.periodo_lectivo = pl.periodo_lectivo and pl.periodo = p.periodo and p.anio_academico = 2010 and p.periodo_generico in (1,2,3) -- 1er, 2do Cuat y Anual -- para achicar la cantidad de inscriptos por comision... and mod(c.comision,3) = mod(a.alumno,30) and ((mod(c.comision,2) = 0 and substring(a.legajo from 1 for 1) in ('1','3','4','5','8')) OR (mod(c.comision,2) = 1 and substring(a.legajo from 1 for 1) in ('2','6','7','9')) OR (mod(c.comision,2) = 2 and substring(a.legajo from 1 for 1) in ('3','7','2','6')) ) ; -- Instancia 1 = Regularidad INSERT INTO sga_insc_cursada_instancias (inscripcion, instancia) SELECT inscripcion, 1 FROM sga_insc_cursada; /* case mod(elemento + periodo_lectivo,30) when 1 then 100 when 3 then 105 when 8 then 102 when 20 then 108 when 15 then 101 when 9 then 107 when 24 then 106 when 13 then 104 when 18 then 107 when 24 then 103 else NULL end, -- Catedra */ SELECT setval('sga_insc_cursada_seq', (SELECT MAX(inscripcion) FROM sga_insc_cursada)); COMMIT WORK;