Master / Detail auto filling of Foreign Keys not working.
Posted: Wed 07 Mar 2012 13:33
Hi,
According to the Help files, the SDAC components should automatically fill in the Foreign Key fields in your Detail DataSet with the Primary Key Field value from the Master Dataset, even if you use a parameter in your Detail Query. Sadly ... it doesn't seem to work in my case (SDAC 6.1.5 in RAD Studio XE2 with Update 4).
I have 2 TMSQuery components on my Form and one DataSource. The DataSource points to the Master Query and the master query has a 'SELECT * FROM T_WAREHOUSE' SQL Statement. The Detail DataSet has a 'SELECT * FROM T_ZONE WHERE WarehouseId = :WarehouseId' SQL Statement and it's Mastersource points to the correct TDatasource.
When running my application the Master / Detail relation is working perfectly. But when I insert an new record into the Detail dataset the WarehouseId field doesn't get filled with the value from the Master DataSet automatically.
It works fine when I use the MasterFields / DetailFields combo ... but in that case it would add and additional ' AND WarehouseId = :WarehouseId' to the Detail Query's SQL Statement.
According to the 'Working with Master / Detail Relationships' topic in the help files, it should also work in my default setup, so I guess this is some form of a bug ?
Regards,
Stefaan
According to the Help files, the SDAC components should automatically fill in the Foreign Key fields in your Detail DataSet with the Primary Key Field value from the Master Dataset, even if you use a parameter in your Detail Query. Sadly ... it doesn't seem to work in my case (SDAC 6.1.5 in RAD Studio XE2 with Update 4).
I have 2 TMSQuery components on my Form and one DataSource. The DataSource points to the Master Query and the master query has a 'SELECT * FROM T_WAREHOUSE' SQL Statement. The Detail DataSet has a 'SELECT * FROM T_ZONE WHERE WarehouseId = :WarehouseId' SQL Statement and it's Mastersource points to the correct TDatasource.
When running my application the Master / Detail relation is working perfectly. But when I insert an new record into the Detail dataset the WarehouseId field doesn't get filled with the value from the Master DataSet automatically.
It works fine when I use the MasterFields / DetailFields combo ... but in that case it would add and additional ' AND WarehouseId = :WarehouseId' to the Detail Query's SQL Statement.
According to the 'Working with Master / Detail Relationships' topic in the help files, it should also work in my default setup, so I guess this is some form of a bug ?
Regards,
Stefaan