Hello,
sorry for my poor english . I am using C++ builder 6.0+ZEOSDBO-6.6.6-stable+mysql 5.0 and not familiar with zeosdbo, when i just use ParamByName function in sql for WHERE clause just like:
FMain->ZQuery1->SQL->Add("select slot from board where eqpid=:id");
FMain->ZQuery1->ParamByName("id")->AsInteger=1;
FMain->ZQuery1->Open();
That works fine.
But when I try to use ParamByName function for column and table name, it returned error. The code is below:
FMain->ZQuery1->SQL->Add("select :col from :tab where eqpid=:id");
FMain->ZQuery1->ParamByName("col")->AsString="slot;
FMain->ZQuery1->ParamByName("tab")->AsString="board";
FMain->ZQuery1->ParamByName("id")->AsInteger=1;
FMain->ZQuery1->Open();
it will return error:
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 ''board' where eqpid=1' at line 1.
The sql I expected should be "select slot from board where eqpid=1", but the real sql seems not like that. Could someone help me?
Any replies will be appreciated.
Could the ParamByName function be used for column and table?
Moderators: gto, EgonHugeist
-
- Fresh Boarder
- Posts: 5
- Joined: 01.01.2014, 06:41
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: Could the ParamByName function be used for column and ta
Hello detective0922,
you canot use parameters for column names and table names. Parameters can only be used for sending values to the RDBMS. This is a limitation of SQL and Zeos doesn't replace the parameters by itself - it only transports them to the RDBMS which in turn has to process it.
Best regards,
Jan
you canot use parameters for column names and table names. Parameters can only be used for sending values to the RDBMS. This is a limitation of SQL and Zeos doesn't replace the parameters by itself - it only transports them to the RDBMS which in turn has to process it.
Best regards,
Jan
-
- Fresh Boarder
- Posts: 5
- Joined: 01.01.2014, 06:41
Re: Could the ParamByName function be used for column and ta
marsupilami wrote:Hello detective0922,
you canot use parameters for column names and table names. Parameters can only be used for sending values to the RDBMS. This is a limitation of SQL and Zeos doesn't replace the parameters by itself - it only transports them to the RDBMS which in turn has to process it.
Best regards,
Jan
Hi, marsupilami, thank you very much for your reply, it is helpful.