Subject Re: [IBO] Updating detail TIBOQuery causes PK violation
Author Helen Borrie
At 06:28 PM 8/12/2003 +0000, you wrote:
>I have a M/D relationship between 2 TIBOQuerys where the detail query
>uses a DataSource and has a parameter for the detail query.
>
>When I go to change a value in the detail query and the update SQL is
>prepared, it uses the master_id field as the record identifier rather
>then the record identifier. (But it just makes that assumption about
>it--I did not set a record identifier anywhere... where would I?)
>
>Below is the detail query. The master field identifier is
>TAXTABLE_ID, the detail field identifier is not shown (TAXYEAR_ID).


> object qryYears: TIBOQuery
> Params = <>
> AutoFetchAll = True
> DatabaseName = 'APTAXFILES_1'
> IB_Connection = ibConn

Dual KeyLinks doesn't belong in a M/D relationship...wrong column chosen
for Keylinks as well...
> KeyLinks.Strings = (
> 'TAXTABLE_ID = :TAXTABLE_ID')

KeyLinks.Strings = (
'TAXYEAR_ID')

> ReadOnly = True
> RecordCountAccurate = True
> DataSource = dsTables


> JoinLinks.Strings = (
> 'TAXTABLE_ID=:TAXTABLE_ID')
Should not be here. JoinLinks has nothing to do M/D - it is for listing
the joining columns in an SQL-89-style inner join query

> SQL.Strings = (
> 'select * from TaxYear')
> FieldOptions = []
>...<field list/>
>
>Is there a way to set the record identifier?

If you mean the PK of the detail table: If it is a generator, use
GeneratorLinks for it. If not, you'll have to pass it yourself.

If you mean the foreign key value for the TaxYear table, the Datasource
linkage will cause the TAXTABLE_ID to be picked up automatically from the
master table.


>I realize I set the EditSQL statement (which I have done) but it
>seems that I am doing something wrong in the SQL as I haven't had to
>do this before (with other backends).

You don't need to set the EditSQL for this. Just set up the properties
correctly and it will be automatic.

Helen