Subject A new question about TIBOTable
Author jacobhavkrog
Hi!

I've got a new problem in my BDE to Firebird migration, and I suspect its related to transaction management, which is non existant in my BDE app.

Here is what I'm trying to do: In my old code I've got two TTable components

AddressTable: TTable;
PersonTable: TTable;

connected to two tables "Address" and "Person" in a Paradox database.

The Person table has a field called AddressNo referring to an entry in the Address table.

Now I want to create a new entry in the person table. In the process I need a new entry in the address table:

consider the call:

AddPerson('Joe', 'High street 7');

procedure TForm1.AddPerson(APersonName, AStreet: string);
var
ID: Integer;
begin
ID := MakeAddress(AStreet);
with PersonTable do begin
Open;
Append;
FieldByName('PersonName').AsString := APersonName;
FieldByName('AddressNo').AsInteger := ID;
Post;
Close;
end;
end;

function TForm1.MakeAddress(AStreet: string): Integer;
begin
with AddressTable do begin
Open;
Append;
FieldByName('Street').AsString := AStreet;
Post;
Result := FieldByName('AddressNo').AsInteger;
Close;
end;
end;

When porting this to corresponding IBO components, I get this error:

violation of FOREIGN KEY constraint "INTEG_185" on table "PERSON" Foreign key reference target does not exist.

It seems the newly created record in the address table isn't visible at the point of posting to the person table...

I know for sure, that a valid ID is returned.

Can you please help me on this one?

Thanks!
Jacob