Page 1 of 1

Delphi7 - mysql 4.1 user variable

Posted: 13.10.2005, 11:28
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


.

Posted: 13.10.2005, 14:04
by zippo
"SELECT @Platz:= (@Platz + 1)" is wrong

Ithink it should be

SELECT @Platz= (@Platz + 1)

":=" is valid only in Delphi, not in SQL.

Posted: 13.10.2005, 14:05
by zippo
Any yes - do not use umlats --> use only ASCII characters for field names!

Posted: 13.10.2005, 15:16
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

Posted: 13.10.2005, 16:32
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?

Posted: 13.10.2005, 16:45
by martin
Hi,

i am using following Version of ZeosLib

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


martin

Posted: 01.11.2005, 06:31
by dhongu
Set ParamCheck with false

Posted: 05.11.2005, 19:03
by zippo
It worked?