SET client_min_messages = notice;
DO $$
DECLARE
_msj TEXT;
__id_estu INTEGER DEFAULT 71;
__cod_fam CHARACTER VARYING;
i INTEGER;
BEGIN
SELECT cod_familia INTO __cod_fam FROM sima.detalle_alumno WHERE nid_persona = __id_estu;
DELETE FROM persona_x_aula WHERE __id_persona=__id_estu;
DELETE FROM medico.ficha_medica WHERE nid_persona = __id_estu;
DELETE FROM pagos.condicion_x_persona WHERE _id_persona = __id_estu;
DELETE FROM pagos.audi_movimiento WHERE _id_movimiento IN (SELECT id_movimiento FROM pagos.movimiento WHERE _id_persona = __id_estu);
DELETE FROM pagos.movimiento WHERE _id_persona = __id_estu;
DELETE FROM persona_x_aula WHERE __id_persona = __id_estu;
DELETE FROM medico.historial_medico WHERE nid_persona = __id_estu;
DELETE FROM psico.ficha_psicologica WHERE _id_persona = __id_estu;
DELETE FROM sima.detalle_alumno WHERE nid_persona = __id_estu;
DELETE FROM persona WHERE nid_persona = __id_estu;
FOR i IN SELECT id_familiar FROM sima.familiar_x_familia WHERE cod_familiar = __cod_fam LOOP
DELETE FROM sima.familiar_x_familia WHERE id_familiar = i;
DELETE FROM news.persona_x_noticia WHERE _id_persona = i AND flg_persona = '2' ;
DELETE FROM msj_familiares_docentes WHERE id_familiar = i;
DELETE FROM familiar WHERE id_familiar = i;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
GET STACKED DIAGNOSTICS _msj = PG_EXCEPTION_CONTEXT;
RAISE NOTICE 'SE JODIO: % %', SQLERRM, SQLSTATE;
END
$$
SET client_min_messages = notice;
DO $$
DECLARE
_msj TEXT;
__id_estu INTEGER DEFAULT 71;
__cod_fam CHARACTER VARYING;
i INTEGER;
BEGIN
SELECT cod_familia INTO __cod_fam FROM sima.detalle_alumno WHERE nid_persona = __id_estu;
DELETE FROM persona_x_aula WHERE __id_persona=__id_estu;
DELETE FROM medico.ficha_medica WHERE nid_persona = __id_estu;
DELETE FROM pagos.condicion_x_persona WHERE _id_persona = __id_estu;
DELETE FROM pagos.audi_movimiento WHERE _id_movimiento IN (SELECT id_movimiento FROM pagos.movimiento WHERE _id_persona = __id_estu);
DELETE FROM pagos.movimiento WHERE _id_persona = __id_estu;
DELETE FROM persona_x_aula WHERE __id_persona = __id_estu;
DELETE FROM medico.historial_medico WHERE nid_persona = __id_estu;
DELETE FROM psico.ficha_psicologica WHERE _id_persona = __id_estu;
DELETE FROM sima.detalle_alumno WHERE nid_persona = __id_estu;
DELETE FROM persona WHERE nid_persona = __id_estu;
FOR i IN SELECT id_familiar FROM sima.familiar_x_familia WHERE cod_familiar = __cod_fam LOOP
DELETE FROM sima.familiar_x_familia WHERE id_familiar = i;
DELETE FROM news.persona_x_noticia WHERE _id_persona = i AND flg_persona = '2' ;
DELETE FROM msj_familiares_docentes WHERE id_familiar = i;
DELETE FROM familiar WHERE id_familiar = i;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
GET STACKED DIAGNOSTICS _msj = PG_EXCEPTION_CONTEXT;
RAISE NOTICE 'SE JODIO: % %', SQLERRM, SQLSTATE;
END
$$
DO $$
DECLARE
_msj TEXT;
__id_estu INTEGER DEFAULT 71;
__cod_fam CHARACTER VARYING;
i INTEGER;
BEGIN
SELECT cod_familia INTO __cod_fam FROM sima.detalle_alumno WHERE nid_persona = __id_estu;
DELETE FROM persona_x_aula WHERE __id_persona=__id_estu;
DELETE FROM medico.ficha_medica WHERE nid_persona = __id_estu;
DELETE FROM pagos.condicion_x_persona WHERE _id_persona = __id_estu;
DELETE FROM pagos.audi_movimiento WHERE _id_movimiento IN (SELECT id_movimiento FROM pagos.movimiento WHERE _id_persona = __id_estu);
DELETE FROM pagos.movimiento WHERE _id_persona = __id_estu;
DELETE FROM persona_x_aula WHERE __id_persona = __id_estu;
DELETE FROM medico.historial_medico WHERE nid_persona = __id_estu;
DELETE FROM psico.ficha_psicologica WHERE _id_persona = __id_estu;
DELETE FROM sima.detalle_alumno WHERE nid_persona = __id_estu;
DELETE FROM persona WHERE nid_persona = __id_estu;
FOR i IN SELECT id_familiar FROM sima.familiar_x_familia WHERE cod_familiar = __cod_fam LOOP
DELETE FROM sima.familiar_x_familia WHERE id_familiar = i;
DELETE FROM news.persona_x_noticia WHERE _id_persona = i AND flg_persona = '2' ;
DELETE FROM msj_familiares_docentes WHERE id_familiar = i;
DELETE FROM familiar WHERE id_familiar = i;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
GET STACKED DIAGNOSTICS _msj = PG_EXCEPTION_CONTEXT;
RAISE NOTICE 'SE JODIO: % %', SQLERRM, SQLSTATE;
END
$$
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.