Well, after trying everything with no success, I resolved to request some help here.
I don't know why, but no matter what library I use for the thread pool, no matter how I execute the querys in database, Im still getting the same errors. Seems the querys of one thread blends with others. Check this error log:
Code: Select all
-----------------------
function: procCountById() <--the function. Ok!
Arg value: 55 <--parameter received. Ok!
MyQuery: SELECT COUNT(*) FROM clients WHERE ID = 55 <--MyQuery = string variable, in the next line of code I will execute this query!. Ok!
Error 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 'dbname.clients LIKE '%'' at line 1 <--Fail. The executed query isn't the same query of MyQuery variable.
------------------------
-----------------------------------------------
Function: UpdateClientProcCount() <--the function. Ok!
Arg Value: 185 <--parameter received. Ok!
MyQuery: UPDATE clients SET NumProcs = 2 WHERE ID = 185 <--MyQuery = string variable, in the next line of code I will execute this query!. Ok!
Error 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 'D = 185' at line 1 <--Same error. The query just broke here, I don't know why
-----------------------------------------------
Here is the sample function:
Code: Select all
procedure TMyDataBase.SetProcessFlag(ProcessID: Integer; Flag: Integer = PROC_OK);
var
Query: TZQuery;
eMsg: string;
begin
try
//Probably, you are thinking: Why you're creating one TZQuery for each procedure ? Well, Doesn't matter if I create one TZQuery in private section of my object, or create one in each procedure/function, this erros still happens.
Query:=TZQuery.Create(nil);
Query.Connection:=ZCon;
//Using Format or ParamByName, the error still occur. ---
MyQuery:=Format('UPDATE process SET Stats = 1, Flag = %d WHERE ID = %d', [Flag, ProcessID]);
Query.SQL.Add(MyQuery);
//Im getting this errors using transaction with ExecuteDirect too, I have no ideia how to solve this...
Query.ExecSQL;
Query.Free;
except
On E:Exception do
begin
eMsg:=' '+sLineBreak;
eMsg:=eMsg + '-----------------------------------------------'+sLineBreak;
eMsg:=eMsg + 'Function: SetProcessFlag()'+sLineBreak;
eMsg:=eMsg + 'Arg Value: '+IntToStr(ProcessID)+' -- '+IntToStr(Flag)+sLineBreak;
eMsg:=eMsg + 'MyQuery: '+MyQuery+sLineBreak;
eMsg:=eMsg + 'Error Message: '+E.Message+sLineBreak;
eMsg:=eMsg + '-----------------------------------------------';
debugWrite(eMsg);
end;
end;
end;
Sorry for the English ^^.