Master / Detail TIBDataSet not updating database on Insert

Posted on 2011-04-28
Last Modified: 2013-12-09

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, 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!
Question by:nath0rn

    Expert Comment


    Author Comment

    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?

    Accepted Solution


    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.close; {I had situations where refresh didn't worked as spected};


    Author Comment


    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!)
    LVL 100

    Expert Comment

    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now