Problemas Maestro/Detalle
Jovenes Buenos dias:
Estoy haciendo un reporte anualizado de cuentas bajo el formato MAESTRO DETALLE. Pretendo el mismo salga asi: ene feb mar abr may jun ........ dic total Activo Bancos 520 600 650 700 800 900 ctas x 600 800 550 600 700 800 total 1120 1400 1200 1300 1500 1700 La instruccion para el Query del maestro es: select idbal, cta, descri from lplancta where (idbal='2' or idbal='3' or idbal='7') and nivel='1' Y la instruccion para el detalle es: select distinct c.idbal, m.cta, c.descri, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=1 and year(i.fecha)=2021) as di1, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=2 and year(i.fecha)=2021) as di2, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=3 and year(i.fecha)=2021) as di3, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=4 and year(i.fecha)=2021) as di4, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=5 and year(i.fecha)=2021) as di5, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=6 and year(i.fecha)=2021) as di6, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=7 and year(i.fecha)=2021) as di7, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=8 and year(i.fecha)=2021) as di8, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=9 and year(i.fecha)=2021) as di9, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=10 and year(i.fecha)=2021) as di10, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=11 and year(i.fecha)=2021) as di11, (select sum(i.debe-i.haber) from lcontmov i where i.cta=m.cta and month(i.fecha)=12 and year(i.fecha)=2021) as di12 from lcontmov m, lplancta c where c.idbal=:idbal and m.cta=c.cta and year(m.fecha)=2021 order by m.cta Y el momento de enlazar me da el erro objeto parameter mal definido. ALGUIEN PODRIA POR FAVOR ORIENTARME Y DECIRME DONDE ME ESTOY EQUIVOCANDO |
Además de como tengas definidas las consultas tienes que enlazar ambos TQuery para que se comporten como deseas.
|
maestro detalle
Justamente estoy tratando de enlazar el detalle con el maestro a travez del identificador de balance. Creen que pueda ser el distinct porque en otra consulta sin maestro detalle funciona perfectamente
|
No sé como lo estás enlazando o que usas para los reportes pero si enlazas una TQuery con otra hay muchos modos de hacerlo.
Si lo haces directamente por código para controlar cuando y como se ejecuta al menos en el TQuery que tiene el detalle debes haber definido en TParams de qué tipo son todos esos campos que usas para enlazar: qMaestro: componente que tiene la consulta principal. qDetalle: componente que tiene las líneas de detalle. qDetalle.params: todos los campos por los que enlazas para que la subconsulta sepa de que tipo son y como debe enlazarlos (qDetalle.params[0].name: el nombre de la variable, qDetalle.params[0].DataType: el tipo de dato, ...) Yo lo hago en tiempo de diseño en el propio componente del reporte, pero puedes hacerlo por código si lo necesitas así porque la consulta cambia. |
La franja horaria es GMT +2. Ahora son las 13:47:44. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi