Link to home
Start Free TrialLog in
Avatar of henryreynolds
henryreynoldsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Delphi6 Interbase Querys and Transactions handling

Good Day

I am new with Interbase/Firebird development, currently I am developing client server applications with Firebird using Interbase
components that are ship with Delphi 6 Enterprise.

I my plan is to develop small seperate .exe and then from a main menu application to
call each .exe as needed. The reason i am doing this is, If a problem occurs in a program then I can
quickly fix the program and the client are not affected in any way...I hope this is the best way..

Now my problem is as follows... In all my application I have a datamodule, in the datamodule
I got TIBDatabase component and a TIBtransaction component.
At this stage the properties of the tibtransaction are default.

My application do a normal select staments like this one.
with qryData do
begin
   close;
  sql.clear;
  sql.add('select * from emp');
  open;
end;

We I nedd to Update data, I call a stored procedure and all my code to update or insert are in the stored procedure.

NOW... my data doesnt refresh if I call my select statement, the old data still shows, but if I exit the app and re-run the application
the updated data are there.

Also If I  run two seperate Instances of the same application on my pc, and i run a select and do a update, and i go to the
other exe and run the same select the updated data doesnt show...

HOW MUST I USE TRANSACTION, AND WHAT IS THE RIGHT WAY OF USING TRANSACTION, please i am desperate for help.

One more thing... I dont depend on dbnavigator to update or delete or to refresh data, I  right my one select and use
stored procedures to insert/update data.

Thank you

Henry Reynolds
ASKER CERTIFIED SOLUTION
Avatar of JDSkinner
JDSkinner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of henryreynolds

ASKER

Thank you I will try and see if this work and I will let you know, but I still not sure WHY and what is the correct way of
using transaction with select statements, and which properties of the transaction compent is the most efficient way for select, updates and insert statements, to
minimize network traffic and to avoid dead locks.

Thank you

Henry
Avatar of JDSkinner
JDSkinner

Direct Quote from Delphi 7 Help:-
"All TIBCustomDataSet descendants and TIBSQL need to use a transaction along with a database component to gain access to data in a database."

While you are getting used to this component the ibTransaction.params property can be left blank,
the system will apply a set of default params which should be suitable for most applications.

To reduce the posibility of deadlocks you can use the following structure

ibTransaction1.StartTransaction;
ibQTable1.Insert;
ibQTable1.FieldByName('<FieldName>').AsString := Edit1.Text;
ibQTable1.Post;
ibTransaction1.Commit; // end of transaction1
( or  IBTransaction1.Rollback or IBTransaction1.RollbackRetaining if applicable)

Have a look at "Interbase Developers Guide" which ships with Interbase in PDF format.
The section called "Using a transaction component" in Chapter 10 "Building One- and
Two-Tiered Applications " should give you a better idea of how this component works.

If you are working with a remote database also read "Interbase Developers Guide"
Chapter 16, “Working with Cached Updates.” as this covers some of your queries regarding
network traffic.

Also
Interbase Operations Guide, Chapter 8 "Database and Server Statistics"
Section "Viewing lock statistics"
Thanx I have a look toady and let you know.
Enjoy your day