[Lazarus] Need some help with UpdateSQL in TSQLQuery and TMySQL50Connection

Joost van der Sluis joost at cnoc.nl
Tue May 27 12:00:06 CEST 2008


Op maandag 26-05-2008 om 18:59 uur [tijdzone -0500], schreef Howard Lee
Harkness:
> Replies below.
> 
> On Mon, May 26, 2008 at 5:04 PM, Joost van der Sluis <joost at cnoc.nl> wrote:
> > Op maandag 26-05-2008 om 16:47 uur [tijdzone -0500], schreef Howard Lee
> > Harkness:
> >> Ok, if I run this as-is, I get some interesting errors. First thing I
> >> noticed is that when I click on "add" in the DBNavigator, the
> >> auto-increment field is not added properly; it's left blank.
> >
> > That's normal. TSQLQuery caches everything. In fact the record isn't
> > made yet, only in memory. So MySQL didn't generate a number yet.
> 
> When I click on "post", there is no ZIPID generated, and while the
> record looks like it got added, when I exit and restart the program, I
> see that nothing actually got inserted. I have to conclude that I'm
> leaving out something (probably a "commit"). I also see that deletes
> don't actually happen, probably for the same reason, and the 'post'
> doesn't generate a 'commit'.

That's true. You have to call 'TSQLQuery.ApplyUpdates' Then all changes
in the local, in-memory changes-buffer are converted into
update/insert/delete statements and executed on the underlying database.

For those connections that do support transactions, you also have to do
TSQLTransaction.Commit(Retaining).

> >> Next, when I exit the program, I get a mysterious error message that
> >> tells me that I attempted to use a type name as an expression, as
> >> reported by procedure DatabaseError in unit db. I get a database error
> >> from just loading the program into Lazarus, and then closing Lazarus.
> >
> > Can you give the literal error-message?
> 
> Certainly. The error message I get on exit from Lazarus is: An
> exception occurred during deletion of
> "SQLTransaction1:TSQLTransaction" Operation cannot be performed on an
> active dataset.
> 
> I do not get this error when running the program outside the IDE.

Then this exception is catched by an try-except statement. But the
IDE/Debugger can't detect that. Probably nothing to worry about. But you
can check if the order in which dataset/transaction etc are closed are
in order.

Joost.




More information about the Lazarus mailing list