Comments - PREPARE Statement

2 months ago Radim Machů

I am fighting with right syntax of PREPARE statement for CONNECT type tables. I run 10.4.12-MariaDB on Windows10 and I use 64-bit ODBC driver to connect tables from MS Access to MariaDB database.

Having a table named fff which is ENGINE=CONNECT TABLE_TYPE=ODBC , I try to run prepared statements on it.

While I have no trouble to run statement with integer type parameter:

set @createStr = ("select * from fff where reltpfak = ? ");
prepare theSQL from @createStr ;
set @i = 1;
execute theSQL using @i;
-- works! 

I can not find a right syntax to pass string variable. My trials lead to an error:

set @createStr = ("select reltpfak from fa where Firma = ? ;");
prepare theSQL from @createStr ;
set @i = "NameOfCompany";
execute theSQL using @i; 

returns Incorrect arguments to EXECUTE .

The same one just with added ' around '?'

set @createStr = ("select reltpfak from fa where Firma = '?' ;")
prepare theSQL from @createStr ;
set @i = "NameOfCompany";
execute theSQL using @i 

returns Error: Got error 174 'SQLExecDirect: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Firma= NameOfCompany'.' from CONNECT .

What is the right syntax of PREPARE statement for CONNECT type tables when passing string variable?

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.