[Lazarus] What is a TSQLTransaction and why do I need one?

Joost van der Sluis joost at cnoc.nl
Wed Dec 1 16:44:08 CET 2010


On Wed, 2010-12-01 at 16:01 +0100, michael.vancanneyt at wisa.be wrote:
> 
> On Wed, 1 Dec 2010, Joost van der Sluis wrote:
> 
> >
> >> Is there somewhere I can hook into the TSQLQuery to (a) see exactly what
> >> query was passed to the server (b) collect any error text and (c) get
> >> execution timing?
> >
> > a) Easiest is to use the database-client's log mechanism. (If there is
> > any). Else you can change the TPQConnection.Preparestatement function.
> > The 'buf' parameter is the actual query. But as you'll see it also adds
> > some more to the query, so it opens a cursor, before it is send to the
> > database-server.
> >
> > b) Ehm.. the error-text is in the exception?
> >
> > c) Hook into TPQConnection.PrepareStatement and TPQCOnnection.Execute
> 
> I am a firm proponent of putting a unified mechanism for a) and c) in 
> TSQLQuery/TSQLConnection, and have, in fact, a patch ready for this
> (it implements a simple event mechanism for the log).

That's a no-brainer. It could als use TCustomApplication.Log, if
Customapplication is assigned. Or, add events before and after an
statement is prepared, executed or unprepared. (And when data is
fetched)

But should we add this code in the connection-objects for each db-type,
or in the code in the sqldb unit?

Joost.








More information about the Lazarus mailing list