1. You will not be able to execute a query like 'select * from: param' because MySQL server does not allow specifying a table name as a parameter. Therefore, such a request will generate an error both in the TMyCommand component and in TMyQuery.
To solve your task, you can use Macros. For example:
Code: Select all
var
TableName: string;
...
MyQuery.SQL.Text: = 'select * from (&TableName)';
TableName: = 'Dept';
MyQuery.MacroByName ('TableName'). Value: = TableName;
MyQuery.Open;
You can learn more about Macros at:
http://www.devart.com/mydac/docs/work_macros.htm
2. When executing the SELECT ... INTO variables statement, the MySQL server does not automatically return the values of the variables. You can verify this by running the queries you have provided using the standard means, for example, mysql.exe Command-Line Client.
To get their values, you should run a query like SELECT @Var; and in this case the server will return a string. As written in the MyDAC documentation
https://www.devart.com/mydac/docs/deva ... ommand.htm - A component for execution of SQL statements and stored procedures which do not return rowsets - therefore you cannot use this component for solving the problem. you should use the TMyQuery component.