We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


What is the difference between post and commit?

ceds98 asked
Medium Priority
Last Modified: 2010-08-05
Which situation do you use post or commit? Does post have autocommit itself?
Watch Question

Hoi ceds98.

I dunno either. But I can guess:
I think commit is used 4 client/server-databases (multiple layer models) working with transactions. In this case u work on a local protocol of changes which r submitted when u commit'em.
On local databases, u use post 2 write back your changes.
Sumthing like that.

Hey guys - could this b correct?

I continue searching 4 more information. If I've got some, I'll post'em.

Post and Commit are different things.

Post writes changes to the current record to the database.
Commit makes database changes permanent.

From help ...
By default, Delphi provides implicit transaction control for your applications through
the Borland Database Engine (BDE). When an application is under implicit transaction
control, Delphi uses a separate transaction for each record in a dataset
that is written to the underlying database.
It commits each individual write operation, such as Post and AppendRecord.

If you want work with explicit transaction control
you may use TDatabase component and its method
StartTransaction, Commit, Rollback.

Difference on example:
Implicit transaction:
for this operation Delphi uses separate transaction
  Database.StartTransaction;  // Implicit
    Table1.Post; // your operation
    Database.Commit; // implicit  make database changes permanent
    Database.Rollback; // rollback database changes(Table1.Post) implicit

Explisit transaction:
you write
    /// many many database changes
    Database1.Commit;  // make ALL changes from StartTransaction permanent
    Database1.Rollback;  // rollback ALL changes from StartTransaction

You can use Transaction not only for client-server databases.
BDE allow use Transaction for DBase, Paradox etc
(But there is restriction for this databases on number of rows in transaction)

My english is not very good. Does transaction means cached updates? Things like commit and rallback are used with cached updates...

Transaction and cached updates are 2 different things...

Look at a transaction as a try except block on the server side...you are basically telling the server or in the case of local database the engine...to protect a block of records...

If everything goes as planned we commit the records...should anything go wrong after we start the Transaction roll all records since we started a transaction back...

In cached updates(everything is client side)...we are keeping all changes local until we apply the updates or discard them they stay local...though we could implement a form of transaction scope on the client side...we still most likely still want to protect our apply updates in a transaction in case anything goes wrong...


The difference between commit and post is:
 1: Post notifies server that a record has been changed.
 2: Commit makes the change permanent.
Your code would look like:
 table1.fieldbyname('field1').asstring := 'Hello World';
 (other fields changed)
 table1.post; //Sends change to server but not committed
Now commit is only necessary when you use a database component and transactions.
Commit has nothing to do with cached updates.
Commit is on the server side not the client side.

Don't we just love new people...=)-~

I guess they don't read the comments...



To vladika
Thank you very much.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.