Subject MASTER-DETAIL with specific requests
Author radevojvodic
Hi All,

I want to make a master-detail form for entering data with some
specific requests. In master query i have some calculated fields that
sumarize data from child. SQL is like this:
SELECT GKNAL.GKNAL_ID
, GKNAL.GKNAL_DAT
, GKNAL.GKNAL_OPIS
, (Select SUM(GKDNEV_DUG) From GKDNEV D
Where GKNAL.GKNAL_ID = D.GKNAL_ID) AS DUG
, (Select SUM(GKDNEV_TRA) From GKDNEV D
Where GKNAL.GKNAL_ID = D.GKNAL_ID) AS TRA
, (Select SUM(GKDNEV_DUG)-Sum(GKDNEV_TRA) From GKDNEV D
Where GKNAL.GKNAL_ID = D.GKNAL_ID) AS SALDO
FROM GKNAL
FOR UPDATE

SQL of child is:
SELECT D.GKNAL_ID
, D.GKDNEV_ID
, D.KONTO_ID
, D.GKDNEV_DUG
, D.GKDNEV_TRA
, D.VALUTA_ID
, (Select V.VALUTA_ZNAK From VALUTA V
Where D.VALUTA_ID = V.VALUTA_ID) AS VALUTA
, D.GKDNEV_KURS
, D.GKDNEV_D_DUG
, D.GKDNEV_D_TRA
FROM GKDNEV D
FOR UPDATE

My form has Edits for parent table fields that can be entered and
IB_Text for calculated fields. For child query there is a grid. The
problem is that when I enter new data in grid changes are not
displayed in IB_text components until I refresh parent table. The
only workaround that I found is to set DMLCacheflags to anounce and
receive and write OnDMLCache... procedure for child table to refresh
parent table. Both queries are bound to same transaction component.
I'm currently working with IBO4G, IBase 6 and delphi 6.

Is there a better solution for this kind of problem?

Another problem is with lookup fields. Even everything is setup OK
with Lookup Combo box if I try to set up default values in the
database after the insert the default value is not shown in lookup
combo box but in edits default values are shown OK. What could be the
problem?