user variables with ":="

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
Odelaine
Posts: 2
Joined: Tue 29 Aug 2006 14:33

user variables with ":="

Post by Odelaine » Tue 29 Aug 2006 14:49

Hi,

I've a big problem with setting user variables in MySQL.
Always when I try to use the syntax with ":", e.g. "SET @A := 1",
I get a strange error message (Exception EDatabaseError):
"Fehlender Wert fuer Parameter '='" --> "Missing value for parameter '='".

Example in Delphi:

SQLQLocalOnly.SQL.Add('SET @counter := 0; ');
SQLQLocalOnly.SQL.Add(
'UPDATE tbl1, ' +
'( ' +
'SELECT ' +
'(@counter := @counter+1) AS nummerierung, ... ' +
'FROM tbl3 ' +
'WHERE (...) ' +
'ORDER BY ... DESC ' +
') AS tbl2 ' +
'SET tbl1.platzierung = tbl2.nummerierung ' +
'WHERE (...) ';
SQLQLocalOnly.ExecSQL;

This example is working with phpMyAdmin properly, so Database and Statement should be OK.
All other MySQL-Statements are working properly with the corelab driver so far, so Installation should be OK.
In the first line I can use 'SET @counter = 0; ' instead of 'SET @counter := 0; ' which is working, but this syntax isn't allowed in the SELECT statement.

EDIT: I use dbexpmda.dll version 3.0 in TSQLConnection (Delphi 7.0)

Please give me any advices to solve this issue.

Best Regards
Ingolf :?
Last edited by Odelaine on Wed 30 Aug 2006 08:44, edited 1 time in total.

Guest

Re: user variables with ":="

Post by Guest » Wed 30 Aug 2006 08:42

Odelaine wrote:Hi,

I've a big problem with setting user variables in MySQL.
Always when I try to use the syntax with ":", e.g. "SET @A := 1",
I get a strange error message (Exception EDatabaseError):
"Fehlender Wert fuer Parameter '='" --> "Missing value for parameter '='".

Example in Delphi:

SQLQLocalOnly.SQL.Add('SET @counter := 0; ');
SQLQLocalOnly.SQL.Add(
'UPDATE tbl1, ' +
'( ' +
'SELECT ' +
'(@counter := @counter+1) AS nummerierung, ... ' +
'FROM tbl3 ' +
'WHERE (...) ' +
'ORDER BY ... DESC ' +
') AS tbl2 ' +
'SET tbl1.platzierung = tbl2.nummerierung ' +
'WHERE (...) ';
SQLQLocalOnly.ExecSQL;

This example is working with phpMyAdmin properly, so Database and Statement should be OK.
All other MySQL-Statements are working properly with the corelab driver so far, so Installation should be OK.
In the first line I can use 'SET @counter = 0; ' instead of 'SET @counter := 0; ' which is working, but this syntax isn't allowed in the SELECT statement.

EDIT: I use dbexpmda.dll version 3.0 in TSQLConnection (Delphi 7.0)

Please give me any advices to solve this issue.

Best Regards
Ingolf :?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 30 Aug 2006 10:06

Parameters are parsed by SQLQuery of dbExpress (in unit SqlExpr, TSQLQuery.QueryChanged method) but not by our driver. To prevent this behaviour you can set ParamCheck option of SQLQuery to False.

Odelaine
Posts: 2
Joined: Tue 29 Aug 2006 14:33

Re: user variables with ":="

Post by Odelaine » Wed 30 Aug 2006 11:31

That easy is this!

Many Thanks for giving me this small, but vital hint.

Ingolf

Post Reply