Subject Re: [IBO] Master-Detail POST problem: REF0 is a required field
Author Helen Borrie
At 04:23 PM 27/11/2005 +0100, you wrote:
>I'm wokring on this problem for a while now, maybe somebody here
>on the list can give me a hint ...
>In a master-detail relationship of IB_Queries, I'm always getting the
>error "REF0 is a required field" when I try to post an insert to the
>detail table.
>But the values of the detail set are all set...

Send more information, such as:

What are the primary keys of the master and the detail?
What is the foreign key of the detail?

Tell us your actual settings for:

---the Mastersource and Masterfields properties of the detail.
---the Keylinks property of the detail
---any custom SQL for the detail's DML (InsertSQL)

Tell us how the value of Ref0 is being assigned.

Any other settings in either dataset that might be relevant, e.g. ReadOnly,

Place a monitor into your app and show us the output produced when you post
the detail.
>Here's a short test probedure I use to check the critical values and
>submit a post:
> With IB_Query_AAW_Rechnung do //that's the detail query
> Begin
> allocconsole;
> writeln('AAW_Rechnung.ref0:',fieldbyname('ref0').asinteger);
>//FK to the master dataset
> writeln('AAW_Rechnung.ref :',fieldbyname('ref').asinteger);
>//PK of the detail table; generation definied for this in the
> if Modified then Post; //<- this is failing with REF0 is a required
> End;
>The Writeln shows, that both values are set in the dataset
>AAW_Rechnung.ref :25894
This at least says that something is happening to null out Ref0 during the
Post sequence. The question is: what? What immediately comes to mind is
that Ref0 is not, on its own, the primary key, but is part of a composite
primary key on the detail table; and/or that possibly the master has a
composite primary key that is not fully linked from the detail's Masterfields.