UPDATE sima.detalle_alumno
SET graficos_x_familiar = tab.graficos
FROM (WITH familiares AS (
SELECT ARRAY_AGG(fxf.id_familiar) AS familiares,
fxf.cod_familiar
FROM sima.familiar_x_familia fxf
GROUP BY fxf.cod_familiar
)
SELECT (SELECT ARRAY_TO_JSON(ARRAY_AGG(JSONB_BUILD_OBJECT(
'id_fam' , tab._id_familiar,
'config' , '[{
"data": null,
"orden": 1,
"isEmpty": false,
"isFilter": false,
"isVisible": true,
"id_grafico": "GR-021",
"desc_grafico": "Pagos"
},{
"data": null,
"orden": 2,
"isEmpty": false,
"isFilter": false,
"isVisible": true,
"id_grafico": "GR-022",
"desc_grafico": "Noticias"
},{
"data": null,
"orden": 3,
"isEmpty": false,
"isFilter": false,
"isVisible": true,
"id_grafico": "GR-025",
"desc_grafico": "Cumpleaños"
},{
"data": null,
"orden": 4,
"isEmpty": false,
"isFilter": false,
"isVisible": true,
"id_grafico": "GR-024",
"desc_grafico": "Asistencia"
},{
"data": null,
"orden": 5,
"isEmpty": false,
"isFilter": false,
"isVisible": true,
"id_grafico": "GR-026",
"desc_grafico": "Notas finales por periodo"
},{
"data": null,
"orden": 6,
"isEmpty": false,
"isFilter": false,
"isVisible": true,
"id_grafico": "GR-027",
"desc_grafico": "Notas finales por curso"
}]'::JSONB
))) FROM (SELECT UNNEST(familiares) AS _id_familiar) tab) AS graficos,
familiares,
cod_familiar
FROM familiares) tab
WHERE tab.cod_familiar = cod_familia;
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.