Delphi7 - mysql 4.1 user variable

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
martin
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 12.10.2005, 18:19
Location: Germany

Delphi7 - mysql 4.1 user variable

Post by martin »

Dear Everybody,

the following sql statement works with MySql-Control-Center on 4.1 server perfectly

[syntax="sql"]
set @Platz = 0;
SELECT @Platz:= (@Platz + 1) as Platz, RegV, RV, VR, Znr, Züchter, sum(Preise) as Preise, sum(Aspkt) AS Aspkt, sum(Km) AS KM FROM ms_championat_ergebnis
GROUP BY Züchter
ORDER BY Preise DESC, Aspkt DESC ...
[/syntax]

this Delphi7 Procedure doesn`t work

[syntax="DELPHI"]

procedure TForm5.championat_ie_dr();
var i : integer;
begin
with Z_Championat do
begin
close;
sql.Clear;
sql.Add('set @Platz = 0; '+
'SELECT @Platz:= (@Platz + 1) as Platz, RegV, RV, VR, Znr, Züchter, '+
'sum(Preise) as Preise, sum(Aspkt) AS Aspkt, sum(Km) AS KM '+
'FROM ms_championat_ergebnis '+
'GROUP BY Züchter '+
'ORDER BY Preise DESC, Aspkt DESC ');
open;

end;
end;

[/syntax]

The EDatabaseError event wrote:
Incorrect Token followed by ":"

I Think, the problem are the chars :=


Please excuse my bad Englisch :oops:


For your help many thanks in advance


.
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

"SELECT @Platz:= (@Platz + 1)" is wrong

Ithink it should be

SELECT @Platz= (@Platz + 1)

":=" is valid only in Delphi, not in SQL.
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

Any yes - do not use umlats --> use only ASCII characters for field names!
martin
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 12.10.2005, 18:19
Location: Germany

Post by martin »

Dear Zippo,

thanks for quik answering.

With the ASCII Chars you are right, but these is not the problem because the Query works without the USER VARIABLES @Platz fine.

In the MySql Documentation on Point 7.1.4 is wrote that you have to use the chars ":=" to replace the User Variables
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

Hi what version of zeoslib are you using?

the thing here is that ':' is for parameters so when ti parses a ':=' it will tryu ti identry the '=' as aparam name. But As logn as I remeber these correction was done.

Are you using latest version of ZoesLib?
martin
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 12.10.2005, 18:19
Location: Germany

Post by martin »

Hi,

i am using following Version of ZeosLib

6.1.5-stable build at 2004-04-29 07:03:04


martin
User avatar
dhongu
Junior Boarder
Junior Boarder
Posts: 37
Joined: 28.09.2005, 08:37
Location: Bucuresti
Contact:

Post by dhongu »

Set ParamCheck with false
Dorin Hongu
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

It worked?
Post Reply