Individual JSON's

This commit is contained in:
Your Name
2025-01-20 15:44:19 -06:00
parent 05e1f7983b
commit 37f4cc42c1
2 changed files with 35 additions and 11 deletions

View File

@@ -38,11 +38,12 @@ try {
SELECT * FROM PUBLIC.AUDITORIA_MAT
WHERE FACULTAD_ID = COALESCE(:facultad_id, FACULTAD_ID)
AND REGISTRO_FECHA_IDEAL + HORARIO_HORA between :fecha_inicio AND :fecha_fin
), DELETION AS (
DELETE FROM last_auditoria
WHERE usuario_id = :usuario_id
), INSERTION AS (
INSERT INTO last_auditoria VALUES (:usuario_id , COALESCE((
SELECT jsonb_agg(AUDITORIA_DATA) FROM AUDITORIA_DATA
), '[]'::JSONB))
ON CONFLICT (usuario_id) DO UPDATE SET auditoria = EXCLUDED.auditoria
INSERT INTO last_auditoria
SELECT :usuario_id, to_jsonb(AUDITORIA_DATA) FROM AUDITORIA_DATA
)
SELECT
registro_id,