Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

Problem with Delphi and Firebird (interbase) database

We have two different programs.  One is written in Borland C++ builder and the other in Delphi.  THey are accessing one central database.  When the C app updates the database the database refects the change without a problem.  When the Dephpi app udates it works as well, but if the Delphi program runs the same Query twice :

Select * from X

and the C app has updated the X table in between the quereies the the Delphi app does not see the update.

If the Delphi app closes it's connection to the database and then re-opens it the it sees the change that was made by the C++ app.  This works but uses alot of resources to accomplish.

Does anyone have any better ideas......



Thanks!!!


0
danielrsmith
Asked:
danielrsmith
1 Solution
 
JDSkinnerCommented:
Hi
What database are you using.
It would help if you posted the section of code used to make the delphi SQL enquiry.
0
 
sun4sundayCommented:
The record will reflect in the database after the Commit.
After commit, try to run the query and check the result in Delphi.
Still giving the problem, try
-- Close and  open the query
-- Refresh query

Work around this.

Still problems, post the code here.

sun4sunday
0
 
calinutzCommented:
The application that does the update should do it in a UPDATE statement and then the update will be seen by the other application on a refresh table. If the update is made in a DBGrid that has a TTable as datasource, then you must check to see if TableDirect is set to true (for ADO components) or just ensure that you call Table1.CommitUpdates for BDE components.
You must realize that the dataset components are not live ones... you must do the refresh yourself. Also consider commiting the updates more often in your applications so that the updates can reach the database and not be kept locally in a cache.
   What components do you use for working with Fireebird... it could be something about those components.

Regards
0
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!

 
danielrsmithAuthor Commented:
I will post some of the code in the morning.  the person working on the Delphi side is not available today.
I am commiting the UPDATE changes after each change.  I have no problem seeing these updates on the C++ side immediately.

The Delphi side refreshes its Query about every 30 seconds and does not get the updates fro some reason.  If I look at the DB through ibconsole the changes are alway there immediately.

Thanks for the help so far!!
0
 
TheRealLokiSenior DeveloperCommented:
Try checking the TIBTransaction's Isolation properties (double click on the TIBTransaction in delphi)
It should be set to at least
read_committed (read_committed, rec_version, nowait)
This could be the problem.

If the delphi app commits the transaction, and starts a new transaction before running the sql query, then it will see the changes.

btw, another approach to the "polling every 30 seconds" would be to use Interbase/Firebird "Events"
so that the database would tell the delphi app if a change had been made, and it needed to refresh its' list

CREATE TRIGGER TRG_SOMETABLE_AFTERINSERT FOR SOMETABLE
ACTIVE AFTER INSERT POSITION 0
as
begin
    post_event 'UpdatedSomeTable';
end

Then, in the delphi app, you drop a TIBEvents on teh form, edit it's properties and add 'UpdatedSomeTable'
Then, when it fires the event, you can do a refresh if convenient
0
 
DelphianCommented:
Appear to me that TheRealLoki got a good clue, since appear that the
TransIsolations is set to SnapShot (or Repeatable Read - if we use ANSI
terminology).

The "only getting refreshed after closing the application" sympton denote
other thing: some problems with transaction management. Maybe you have more
than TIBTransaction component and it being held open - therefore blocking
the Query to see the updates. Since FireBird/Interbase can have multiple
transactions for a same connection, this scenario is very possible.


0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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