Complete newbie question!

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
GVP
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 10.02.2009, 15:23

Complete newbie question!

Post by GVP »

Hello,

A complete newbie, so be gentle!
Using Delphi 6, Zeoslib 6.6.4 & MySQL 5.1.31 under Windows.

When I try a multi-row update like this:

Code: Select all

    QuotesZQuery.SQL.Clear;
    QuotesZQuery.SQL.Add('UPDATE LineItemTable SET DesignTime = ' + IntToStr(55) + ' WHERE Projectnumber=504 AND LineNumber=1;');
    QuotesZQuery.SQL.Add('UPDATE LineItemTable SET DesignTime = ' + IntToStr(55) + ' WHERE Projectnumber=505 AND LineNumber=1');
    QuotesZQuery.ExecSQL;

I get this error message:

"Project quoteit.exe raised exception class EZSQLException with message 'SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE LineItemTable SET DesignTime = 55 WHERE Projectnumber=505 AND LineNumber=' at Line 2. Process stopped. Use Step or Run to continue."

The query executes fine if it is only one line.

I have indeed looked in the MySQL manual, but can't find the answer - though I suspect it will turn out to be obvious!

Can anyone help me, please?

Thanks.
humantool
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 10.02.2009, 17:16

Post by humantool »

hi,
a coma is missing at the end of line 2, maybe ?
DarylC
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 07.02.2009, 05:56

Post by DarylC »

I don't think you can execute multiple update statements at once.

Try this
QuotesZQuery.SQL.Clear;
QuotesZQuery.SQL.Add('UPDATE LineItemTable SET DesignTime = ' + IntToStr(55) + ' WHERE Projectnumber=504 AND LineNumber=1;');
QuotesZQuery.ExecSQL;

QuotesZQuery.SQL.Clear;
QuotesZQuery.SQL.Add('UPDATE LineItemTable SET DesignTime = ' + IntToStr(55) + ' WHERE Projectnumber=505 AND LineNumber=1');
QuotesZQuery.ExecSQL;


This way you are executing each statement separately.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Also : you could use the TZSQLProcessor component. That one is made for multiple statements.

Something else : you could put ZConnection1.Properties.Add('CLIENT_MULTI_STATEMENTS=1'); in your code (or add the property line at design time.
Normally that should work as well.

Mark
Image
GVP
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 10.02.2009, 15:23

Post by GVP »

Thank you all.

I'm looking into the TZSQLProcessor component, and it seems to be the solution. Thanks again.
Post Reply