Page 1 of 1

master detail problem

Posted: Mon 27 Nov 2006 13:47
by luis_augusto
I have two tables:

MasterTable Orders x DetailTable Quotations
Supplier;Order (detailfields) x Winner;Order (masterfields) both non-primary keys

Order is Autoinc

During insert process, Order is null in both tables.
Supplier = 'Supplier 1'
and
Winner = 'Supplier 1';

Detail records are not available, but they should, since the relationship is stablished:

'Supplier 1' = 'Supplier 1'
null = null

How come?

Thanks.

Posted: Tue 28 Nov 2006 12:23
by Jackson
Please make sure that:
1. You use SDAC SQL Generator for generating the INSERT statement. If you use your own INSERT statement, you should take care about getting the IDENTITY value after insert.
2. The value of the TCustomMSDataSet.Options.QueryIdentity property is True both in master and detail TMSQuery components.
3. The value of the TCustomDADataSet.ParamCheck property is True both in master and detail TMSQuery components.

master detail

Posted: Tue 28 Nov 2006 17:00
by luis_augusto
The problem is not that I am getting a null value on the identity field.

Orders.Order is, indeed, an Identity field on table orders, but my intention is to get all quotations for a given supplier, whose donĀ“t have an order number (field Quotations.Order is null), yet.

After get them, I will generate an order number and then put it into the quotations's order field.

It seems that, when connecting orders and quotations through the order field, using an Identity field, the value passed to the query is interpreted as zero (not as null). I may be wrong, but the effect that I am experiencing the same (as if I had passed zero as order instead of null).

Posted: Wed 29 Nov 2006 13:30
by Jackson
In such case SDAC SQL Generator generates the following query:
SELECT * FROM detail WHERE MasterID=:p1
When the NULL value is assigned to the 'p1' parameter, query becomes like the following:
SELECT * FROM detail WHERE MasterID=NULL
it is not the same as
SELECT * FROM detail WHERE MasterID IS NULL
So SDAC Master/Detail relationship doesn't support relations by NULL values.

master detail relationship

Posted: Wed 29 Nov 2006 14:22
by luis_augusto
In the future, would be nice if Sdac could support this, since BDE with paradox does.

Thank you, anyway, for the hint. Knowing this, I can workaround the problem.