• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1223
  • Last Modified:

Master / Detail TIBDataSet not updating database on Insert

Hello!

My situation is this. I am currently using Delphi XE and building a simple database app.

The situation involves Instructors and notes for the instructors. So far I have a TIBDataSet for the tblInstructors, and a TIBDataSet for the tblNotes, both with appropriate SQL statements for the insert, delete, etc.

The problem arises when inserting a new Instructor. It will update file (with standard tblInstructors.insert, tblInstructors.post) and having an frmSplash.db_transaction.CommitRetaining; after the post is called. It appears to update fine (by refreshing the table in a separate application for viewing interbase databases, after the post is called). However right after the insert when trying to add a note, it will throw an error (attached in screenshot).

HOWEVER, if I close the application after the instructor has being inserted, then load it again and select the instructor that was inserted, then insert a note, it will work fine.

before the tblnotes are posted, I've put a tblnotesIN_ID.value := tblInstructorsIN_ID.value; to link them, since not havign that will just insert the note without any reference to the instructor. So maybe someone can hint to me the best way to do this, regarading master/detail with TIBDataSet. :)

I hope I have made sense with this, please if anyone has any questions ask away!
error.jpg
0
nath0rn
Asked:
nath0rn
1 Solution
 
nath0rnAuthor Commented:
I don't think it's an issue with how the database is set up.

For some reason it wont reconise the value is in the parent table until the database is disconnected and reconnected.

Do you think it's an issue with transaction types?
0
 
paulo_psaCommented:
Hi,

It seems that the foreign key is created in db side but not available to the detail table in client side.
I suggest you to force a refresh just after insert the master. Anything like:
table.refresh;
table.close; {I had situations where refresh didn't worked as spected}
table.open;

bye
0
 
nath0rnAuthor Commented:
Hi,

Yes this is what I've had to end up doing. But it can get rather messy since the record number is reset, and stuff like that.

I have it at the moment where it will get the latest entry in the table after being reset, and point to that. But it's not really an elegant solution!

I guess if there is no other comments, I'll accept yours as an answer since it's as close to the answer (so far!)
0
 
mlmccCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now