I do not know about the structure of the dabatase you are using, but if you do not use the same column name when assigning you will reproduced (your sample works for me too with the same name). So something like this:
Code: Select all
try
UniQuery1.Connection := UniConnection;
UniQuery1.SQL.Text := 'SELECT SAL FROM EMP';
UniQuery1.Open;
UniQuery2 := TUniQuery.Create(nil);
try
UniQuery2.Connection := UniConnection;
UniQuery2.SQL.Text := 'SELECT * FROM EMP WHERE COMM = :COMM';
UniQuery2.ParamByName('COMM').Value := 50;
UniQuery2.ParamByName('COMM').Assign(UniQuery1.FieldByName('SAL')); //same db type of course but different name between parameter and fieldname
if UniQuery2.ParamByName('COMM').Value <= 0 then
WriteLn('OK');
finally
UniQuery2.Free;
end;
finally
UniQuery1.Free;
end;
By doing this I understand one thing: With ADO, parameter are not named, so when I assign maybe it didnt care about the name (but the position), but now with undac, you take care of the name of the parameter (a good thing!) (and the assign will change the name)... The thing is that it was working before (I dont know extactly how!), I would not do my code like this but I have to manage the existing code!
So is there something to do for you here (preserve the name of the param?), or should I find a work arround and what it could be (change back the name - how?)? What happens here if the param SAL already exist in the query2 (dangerous!)?
Of course I would like your assign keep the original name!

Thanks for your advises