Solved

Problem with Delphi and Firebird (interbase) database

Posted on 2006-06-27
6
407 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 303
Path  to current project in Delphi. 2 79
Delphi Form ownership 4 87
Drag & Drop... Data from one grid to another 2 11
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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