Solved

Problem with Delphi and Firebird (interbase) database

Posted on 2006-06-27
6
405 Views
Last Modified: 2010-08-05
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
Comment
Question by:danielrsmith
6 Comments
 
LVL 4

Expert Comment

by:JDSkinner
ID: 16997079
Hi
What database are you using.
It would help if you posted the section of code used to make the delphi SQL enquiry.
0
 
LVL 9

Expert Comment

by:sun4sunday
ID: 16998057
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
 
LVL 11

Expert Comment

by:calinutz
ID: 16999534
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:danielrsmith
ID: 17002032
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
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 500 total points
ID: 17006229
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
 
LVL 4

Expert Comment

by:Delphian
ID: 17112418
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sending Gmail through Delphi 3 91
Mydac connection data base issue 3 139
Convert Jpg /PNG To GIF 5 120
When I am typing into a TEdit last word repeats 7 117
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

17 Experts available now in Live!

Get 1:1 Help Now