[fpc-pascal] Documentation for sqldb
Joost van der Sluis
joost at cnoc.nl
Mon Jun 25 13:37:53 CEST 2007
On Fri, 2007-06-22 at 10:43 +1000, John wrote:
> Joost van der Sluis wrote:
> > IN principle you can set ReadOnly to false and ParseSQL to true. That
> > way sqldb tries to parse your query. If it's a simple 'select * from
> > table' the TSQLQuery will be updateable. It automatically generates
> > update/delete and insert queries. For the 'where' clause is uses by
> > default the primary key of the table. (That's a setting, upWhereKeyOnly)
> > For example: 'delete * from table where pk=:old_pk'
> > If you edit some data, those changes will be stored in an updatebuffer.
> > With TSQLQuery.CancelUpdates all those changes are lost. But if you
> > call .ApplyUpdates, it will execute one query for every changed record.
> > (That could be a insert, update or delete query)
> So if I change some field values and post the record, that changed data
> goes into the update buffer - of TBufDataset ? I should then be able to
> accumulate a few changes of these, and then, in code, call
> TSQLQuery.ApplyUpdate, and it should be sent to the database ? Should
> this also commit at the database level, or do I have to do this ?
> (I think I tried this, but didn't pursue it very far, because I wasn't
> sure if it even should work)
You have still to commit the database-transaction.
(SQLQuery.Transaction.commit(retaining)) And yes, the buffer is handled
> Would it be feasible / sensible to call ApplyUpdate from an AfterPost
> event handler ?
Yes, you could do that. But that could generate a lot of sql-traffic.
Maybe in an after-scroll is a better idea.
> > Those are the basics. If you have questions, ask them here. And if you
> > have any time, please document it somewhere on the wiki. ;)
> I will, if I get to the point of thinking I understand it enough to not
> make a fool of myself!
Just start it, others will correct mistakes if needed.
More information about the fpc-pascal