Subject Re: How do I post multiple datasets in a single transaction?
Author masonwheeler
For heaven's sake, I know what transactions are! I've been using SQL databases, both Firebird and SQL Server, for years, using a variety of different frameworks. But I have *never* seen a framework that considers all data live and has no concept of local data!

The way sane SQL data access works is like this: You query the database. It pulls the data into local memory. THE TRANSACTION IS CLOSED AT THIS POINT. All your data is now a local copy. You make your changes, then you open a new transaction and save your changes back to the database.

(And before anyone says "but... but... concurrency!", consider this: if two users are trying to edit the same row, the client is going to have to have code to deal with it no matter what; just letting the DB raise an exception and throw it in the user's face is unacceptable. So since you need an explicit client-side locking mechanism of some sort for your data access to work right anyway, there's no good reason to hold the connection open and overcomplicated everything for concurrency's sake.)

All I'm asking is, how do I do local data access and decouple queries from updates in IBO, like you can do in any other framework, even for Firebird?

Is that really such a difficult question?

--- In IBObjects@yahoogroups.com, Rohit Gupta <r.gupta@...> wrote:
>
> Mason,
>
> as Helen said, read up about transactions. They work the way they do in
> firebird (and hence IBO). Your wishing them to change will not make
> them change. What you are describing is how non-sql databases used to
> work such as btrieve. Thats not how firebird works.
>
> If you want multiple datasets to commit/rollback together, yo have to
> start them up with the same transaction, before you fetch data or create
> data.
>
> Rohit
>
> On 25/09/2012 9:20 a.m., masonwheeler wrote:
> >
> > If I was using DBX, and I wanted to ensure that changes from multiple
> > datasets were committed in a single transaction, it would go like this:
> >
> > tran := connection.BeginTransaction;
> > try
> > dataset1.ApplyUpdates;
> > dataset2.ApplyUpdates;
> > connection.CommitFreeAndNil(tran);
> > except
> > connection.RollbackFreeAndNil(tran);
> > end;
> >
> > IBO doesn't seem to work that way. And in fact, as I've just
> > discovered, it doesn't seem to work *at all* when trying to post
> > multiple datasets in one transaction.
> >
> > Here's what I'm trying, using datasets of type TIBOTable:
> >
> > tran := TIB_Transaction.Create(nil);
> > try
> > try
> > tran.IB_Connection := connection;
> > tran.StartTransaction;
> > dataset1.IB_Transaction := tran;
> > dataset2.IB_Transaction := tran;
> > dataset1.ApplyUpdates();
> > dataset2.ApplyUpdates();
> > tran.Commit;
> > except
> > tran.Rollback;
> > raise;
> > end;
> > finally
> > tran.Free;
> > end;
> >
> > The problem with this is that, for some bizarre reason, assigning the
> > transaction object to the dataset SILENTLY CLOSES THE DATASET, which
> > causes all the changes that I'm trying to commit to be lost!
> >
> > What in the world is going on here, and how do I get this to work
> > properly?
> >
> >
> >
> >
> > __________ Information from ESET Endpoint Antivirus, version of virus
> > signature database 7512 (20120924) __________
> >
> > The message was checked by ESET Endpoint Antivirus.
> >
> > http://www.eset.com
>
>
> --
> Regards
>
> *Rohit Gupta*
> B.E. Elec., M.E., Mem IEEE, Member IET
> Technical Director
> Computer Fanatics Ltd
>
> *Tel *4892280
> *Fax *4892290
> *Web *www.cfl.co.nz
> ------------------------------------------------------------------------
> This email and any attachments contain information, which is
> confidential and may be subject to legal privilege and copyright. If you
> are not the intended recipient, you must not use, distribute or copy
> this email or attachments. If you have received this in error, please
> notify us immediately by return email and then delete this email and any
> attachments.
>
>
> [Non-text portions of this message have been removed]
>