Could the ParamByName function be used for column and table?

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

detective0922
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 01.01.2014, 06:41

Could the ParamByName function be used for column and table?

Postby detective0922 » 02.01.2014, 08:42

Hello,

sorry for my poor english :oops: . 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. :D

marsupilami
Gold Boarder
Gold Boarder
Posts: 591
Joined: 17.01.2011, 14:17

Re: Could the ParamByName function be used for column and ta

Postby marsupilami » 02.01.2014, 20:31

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

detective0922
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 01.01.2014, 06:41

Re: Could the ParamByName function be used for column and ta

Postby detective0922 » 03.01.2014, 17:03

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.


Return to “6.6 - stable”

Who is online

Users browsing this forum: No registered users and 1 guest